mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-22 13:40:44 -08:00
(dynamic-completion-mode): New function to enable
the mode. (Just loading the file now does not change anything.)
This commit is contained in:
parent
ebd32d7b07
commit
bb310d1ea9
1 changed files with 134 additions and 142 deletions
|
|
@ -28,8 +28,7 @@
|
||||||
|
|
||||||
;; What to put in .emacs
|
;; What to put in .emacs
|
||||||
;;-----------------------
|
;;-----------------------
|
||||||
;; (load "completion")
|
;; (dynamic-completion-mode)
|
||||||
;; (initialize-completions)
|
|
||||||
|
|
||||||
;;---------------------------------------------------------------------------
|
;;---------------------------------------------------------------------------
|
||||||
;; Documentation [Slightly out of date]
|
;; Documentation [Slightly out of date]
|
||||||
|
|
@ -616,23 +615,6 @@ Used to decide whether to save completions.")
|
||||||
"This variable holds the current completion syntax table.")
|
"This variable holds the current completion syntax table.")
|
||||||
(make-variable-buffer-local 'cmpl-syntax-table)
|
(make-variable-buffer-local 'cmpl-syntax-table)
|
||||||
|
|
||||||
;;-----------------------------------------------
|
|
||||||
;; Installing the appropriate mode tables
|
|
||||||
;;-----------------------------------------------
|
|
||||||
|
|
||||||
(add-hook 'lisp-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(setq cmpl-syntax-table cmpl-lisp-syntax-table)))
|
|
||||||
|
|
||||||
(add-hook 'c-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(setq cmpl-syntax-table cmpl-c-syntax-table)))
|
|
||||||
|
|
||||||
(add-hook 'fortran-mode-hook
|
|
||||||
'(lambda ()
|
|
||||||
(setq cmpl-syntax-table cmpl-fortran-syntax-table)
|
|
||||||
(completion-setup-fortran-mode)))
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
;;-----------------------------------------------
|
||||||
;; Symbol functions
|
;; Symbol functions
|
||||||
;;-----------------------------------------------
|
;;-----------------------------------------------
|
||||||
|
|
@ -875,11 +857,11 @@ Returns nil if there isn't one longer than `completion-min-length'."
|
||||||
;; "The current point position the cdabbrev search is at.")
|
;; "The current point position the cdabbrev search is at.")
|
||||||
|
|
||||||
(defvar cdabbrev-current-window nil)
|
(defvar cdabbrev-current-window nil)
|
||||||
;; "The current window we are looking for cdabbrevs in. T if looking in
|
;; "The current window we are looking for cdabbrevs in.
|
||||||
;; (other-buffer), NIL if no more cdabbrevs.")
|
;; Return t if looking in (other-buffer), nil if no more cdabbrevs.")
|
||||||
|
|
||||||
(defvar cdabbrev-wrapped-p nil)
|
(defvar cdabbrev-wrapped-p nil)
|
||||||
;; "T if the cdabbrev search has wrapped around the file.")
|
;; "Return t if the cdabbrev search has wrapped around the file.")
|
||||||
|
|
||||||
(defvar cdabbrev-abbrev-string "")
|
(defvar cdabbrev-abbrev-string "")
|
||||||
(defvar cdabbrev-start-point 0)
|
(defvar cdabbrev-start-point 0)
|
||||||
|
|
@ -1891,23 +1873,6 @@ Prefix args ::
|
||||||
;; Pretend that we were never here
|
;; Pretend that we were never here
|
||||||
(setq this-command 'failed-complete)
|
(setq this-command 'failed-complete)
|
||||||
))))
|
))))
|
||||||
|
|
||||||
;;-----------------------------------------------
|
|
||||||
;; "Complete" Key Keybindings
|
|
||||||
;;-----------------------------------------------
|
|
||||||
|
|
||||||
(global-set-key "\M-\r" 'complete)
|
|
||||||
(global-set-key [?\C-\r] 'complete)
|
|
||||||
(define-key function-key-map [C-return] [?\C-\r])
|
|
||||||
|
|
||||||
;; Tests -
|
|
||||||
;; (add-completion "cumberland")
|
|
||||||
;; (add-completion "cumberbund")
|
|
||||||
;; cum
|
|
||||||
;; Cumber
|
|
||||||
;; cumbering
|
|
||||||
;; cumb
|
|
||||||
|
|
||||||
|
|
||||||
;;---------------------------------------------------------------------------
|
;;---------------------------------------------------------------------------
|
||||||
;; Parsing definitions from files into the database
|
;; Parsing definitions from files into the database
|
||||||
|
|
@ -1977,8 +1942,6 @@ Prefix args ::
|
||||||
)))
|
)))
|
||||||
))
|
))
|
||||||
|
|
||||||
(add-hook 'find-file-hooks 'cmpl-find-file-hook)
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
;;-----------------------------------------------
|
||||||
;; Tags Table Completions
|
;; Tags Table Completions
|
||||||
;;-----------------------------------------------
|
;;-----------------------------------------------
|
||||||
|
|
@ -2470,17 +2433,6 @@ Also sets up so that exiting emacs will automatically save the file."
|
||||||
))
|
))
|
||||||
(setq cmpl-initialized-p t)
|
(setq cmpl-initialized-p t)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
|
||||||
;; Kill EMACS patch
|
|
||||||
;;-----------------------------------------------
|
|
||||||
|
|
||||||
(add-hook 'kill-emacs-hook
|
|
||||||
'(lambda ()
|
|
||||||
(kill-emacs-save-completions)
|
|
||||||
(cmpl-statistics-block
|
|
||||||
(record-cmpl-kill-emacs))))
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
;;-----------------------------------------------
|
||||||
;; Kill region patch
|
;; Kill region patch
|
||||||
|
|
@ -2510,7 +2462,6 @@ Patched to remove the most recent completion."
|
||||||
(t
|
(t
|
||||||
(kill-region beg end))))
|
(kill-region beg end))))
|
||||||
|
|
||||||
(global-set-key "\C-w" 'completion-kill-region)
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
;;-----------------------------------------------
|
||||||
;; Patches to self-insert-command.
|
;; Patches to self-insert-command.
|
||||||
|
|
@ -2590,61 +2541,7 @@ TYPE is the type of the wrapper to be added. Can be :before or :under."
|
||||||
(funcall (or (and (symbolp this-command)
|
(funcall (or (and (symbolp this-command)
|
||||||
(get this-command 'completion-function))
|
(get this-command 'completion-function))
|
||||||
'use-completion-under-or-before-point)))
|
'use-completion-under-or-before-point)))
|
||||||
(add-hook 'pre-command-hook 'completion-before-command)
|
|
||||||
|
|
||||||
|
|
||||||
;;---------------------------------------------------------------------------
|
|
||||||
;; Patches to standard keymaps insert completions
|
|
||||||
;;---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
|
||||||
;; Separators
|
|
||||||
;;-----------------------------------------------
|
|
||||||
;; We've used the completion syntax table given as a guide.
|
|
||||||
;;
|
|
||||||
;; Global separator chars.
|
|
||||||
;; We left out <tab> because there are too many special cases for it. Also,
|
|
||||||
;; in normal coding it's rarely typed after a word.
|
|
||||||
(global-set-key " " 'completion-separator-self-insert-autofilling)
|
|
||||||
(global-set-key "!" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "%" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "^" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "&" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "(" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key ")" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "=" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "`" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "|" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "{" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "}" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "[" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "]" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key ";" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "\"" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "'" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "#" 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "," 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key "?" 'completion-separator-self-insert-command)
|
|
||||||
|
|
||||||
;; We include period and colon even though they are symbol chars because :
|
|
||||||
;; - in text we want to pick up the last word in a sentence.
|
|
||||||
;; - in C pointer refs. we want to pick up the first symbol
|
|
||||||
;; - it won't make a difference for lisp mode (package names are short)
|
|
||||||
(global-set-key "." 'completion-separator-self-insert-command)
|
|
||||||
(global-set-key ":" 'completion-separator-self-insert-command)
|
|
||||||
|
|
||||||
;; Lisp Mode diffs
|
|
||||||
(define-key lisp-mode-map "!" 'self-insert-command)
|
|
||||||
(define-key lisp-mode-map "&" 'self-insert-command)
|
|
||||||
(define-key lisp-mode-map "%" 'self-insert-command)
|
|
||||||
(define-key lisp-mode-map "?" 'self-insert-command)
|
|
||||||
(define-key lisp-mode-map "=" 'self-insert-command)
|
|
||||||
(define-key lisp-mode-map "^" 'self-insert-command)
|
|
||||||
|
|
||||||
;; Avoid warnings.
|
|
||||||
(defvar c-mode-map)
|
|
||||||
(defvar fortran-mode-map)
|
|
||||||
|
|
||||||
;; C mode diffs.
|
;; C mode diffs.
|
||||||
(defun completion-c-mode-hook ()
|
(defun completion-c-mode-hook ()
|
||||||
(def-completion-wrapper electric-c-semi :separator)
|
(def-completion-wrapper electric-c-semi :separator)
|
||||||
|
|
@ -2663,47 +2560,142 @@ TYPE is the type of the wrapper to be added. Can be :before or :under."
|
||||||
(define-key fortran-mode-map "*" 'completion-separator-self-insert-command)
|
(define-key fortran-mode-map "*" 'completion-separator-self-insert-command)
|
||||||
(define-key fortran-mode-map "/" 'completion-separator-self-insert-command)
|
(define-key fortran-mode-map "/" 'completion-separator-self-insert-command)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
;;; Enable completion mode.
|
||||||
|
|
||||||
;;-----------------------------------------------
|
;;;###autoload
|
||||||
;; End of line chars.
|
(defun dynamic-completion-mode ()
|
||||||
;;-----------------------------------------------
|
"Enable dynamic word-completion."
|
||||||
(def-completion-wrapper newline :separator)
|
(interactive)
|
||||||
(def-completion-wrapper newline-and-indent :separator)
|
(add-hook 'find-file-hooks 'cmpl-find-file-hook)
|
||||||
(def-completion-wrapper comint-send-input :separator)
|
(add-hook 'pre-command-hook 'completion-before-command)
|
||||||
(def-completion-wrapper exit-minibuffer :minibuffer-separator)
|
|
||||||
(def-completion-wrapper eval-print-last-sexp :separator)
|
|
||||||
(def-completion-wrapper eval-last-sexp :separator)
|
|
||||||
;;(def-completion-wrapper minibuffer-complete-and-exit :minibuffer)
|
|
||||||
|
|
||||||
;;-----------------------------------------------
|
;; Install the appropriate mode tables.
|
||||||
;; Cursor movement
|
(add-hook 'lisp-mode-hook
|
||||||
;;-----------------------------------------------
|
'(lambda ()
|
||||||
|
(setq cmpl-syntax-table cmpl-lisp-syntax-table)))
|
||||||
|
(add-hook 'c-mode-hook
|
||||||
|
'(lambda ()
|
||||||
|
(setq cmpl-syntax-table cmpl-c-syntax-table)))
|
||||||
|
(add-hook 'fortran-mode-hook
|
||||||
|
'(lambda ()
|
||||||
|
(setq cmpl-syntax-table cmpl-fortran-syntax-table)
|
||||||
|
(completion-setup-fortran-mode)))
|
||||||
|
|
||||||
(def-completion-wrapper next-line :under-or-before)
|
;; "Complete" Key Keybindings.
|
||||||
(def-completion-wrapper previous-line :under-or-before)
|
|
||||||
(def-completion-wrapper beginning-of-buffer :under-or-before)
|
|
||||||
(def-completion-wrapper end-of-buffer :under-or-before)
|
|
||||||
(def-completion-wrapper beginning-of-line :under-or-before)
|
|
||||||
(def-completion-wrapper end-of-line :under-or-before)
|
|
||||||
(def-completion-wrapper forward-char :under-or-before)
|
|
||||||
(def-completion-wrapper forward-word :under-or-before)
|
|
||||||
(def-completion-wrapper forward-sexp :under-or-before)
|
|
||||||
(def-completion-wrapper backward-char :backward-under)
|
|
||||||
(def-completion-wrapper backward-word :backward-under)
|
|
||||||
(def-completion-wrapper backward-sexp :backward-under)
|
|
||||||
|
|
||||||
(def-completion-wrapper delete-backward-char :backward)
|
(global-set-key "\M-\r" 'complete)
|
||||||
(def-completion-wrapper delete-backward-char-untabify :backward)
|
(global-set-key [?\C-\r] 'complete)
|
||||||
|
(define-key function-key-map [C-return] [?\C-\r])
|
||||||
|
|
||||||
;; Tests --
|
;; Tests -
|
||||||
;; foobarbiz
|
;; (add-completion "cumberland")
|
||||||
;; foobar
|
;; (add-completion "cumberbund")
|
||||||
;; fooquux
|
;; cum
|
||||||
;; fooper
|
;; Cumber
|
||||||
|
;; cumbering
|
||||||
|
;; cumb
|
||||||
|
|
||||||
(cmpl-statistics-block
|
;; Save completions when killing Emacs.
|
||||||
|
|
||||||
|
(add-hook 'kill-emacs-hook
|
||||||
|
'(lambda ()
|
||||||
|
(kill-emacs-save-completions)
|
||||||
|
(cmpl-statistics-block
|
||||||
|
(record-cmpl-kill-emacs))))
|
||||||
|
|
||||||
|
;; Patches to standard keymaps insert completions
|
||||||
|
(substitute-key-definition 'kill-region 'completion-kill-region
|
||||||
|
global-map)
|
||||||
|
|
||||||
|
;; Separators
|
||||||
|
;; We've used the completion syntax table given as a guide.
|
||||||
|
;;
|
||||||
|
;; Global separator chars.
|
||||||
|
;; We left out <tab> because there are too many special cases for it. Also,
|
||||||
|
;; in normal coding it's rarely typed after a word.
|
||||||
|
(global-set-key " " 'completion-separator-self-insert-autofilling)
|
||||||
|
(global-set-key "!" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "%" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "^" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "&" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "(" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key ")" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "=" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "`" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "|" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "{" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "}" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "[" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "]" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key ";" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "\"" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "'" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "#" 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "," 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key "?" 'completion-separator-self-insert-command)
|
||||||
|
|
||||||
|
;; We include period and colon even though they are symbol chars because :
|
||||||
|
;; - in text we want to pick up the last word in a sentence.
|
||||||
|
;; - in C pointer refs. we want to pick up the first symbol
|
||||||
|
;; - it won't make a difference for lisp mode (package names are short)
|
||||||
|
(global-set-key "." 'completion-separator-self-insert-command)
|
||||||
|
(global-set-key ":" 'completion-separator-self-insert-command)
|
||||||
|
|
||||||
|
;; Lisp Mode diffs
|
||||||
|
(define-key lisp-mode-map "!" 'self-insert-command)
|
||||||
|
(define-key lisp-mode-map "&" 'self-insert-command)
|
||||||
|
(define-key lisp-mode-map "%" 'self-insert-command)
|
||||||
|
(define-key lisp-mode-map "?" 'self-insert-command)
|
||||||
|
(define-key lisp-mode-map "=" 'self-insert-command)
|
||||||
|
(define-key lisp-mode-map "^" 'self-insert-command)
|
||||||
|
|
||||||
|
;; Avoid warnings.
|
||||||
|
(defvar c-mode-map)
|
||||||
|
(defvar fortran-mode-map)
|
||||||
|
|
||||||
|
;;-----------------------------------------------
|
||||||
|
;; End of line chars.
|
||||||
|
;;-----------------------------------------------
|
||||||
|
(def-completion-wrapper newline :separator)
|
||||||
|
(def-completion-wrapper newline-and-indent :separator)
|
||||||
|
(def-completion-wrapper comint-send-input :separator)
|
||||||
|
(def-completion-wrapper exit-minibuffer :minibuffer-separator)
|
||||||
|
(def-completion-wrapper eval-print-last-sexp :separator)
|
||||||
|
(def-completion-wrapper eval-last-sexp :separator)
|
||||||
|
;;(def-completion-wrapper minibuffer-complete-and-exit :minibuffer)
|
||||||
|
|
||||||
|
;;-----------------------------------------------
|
||||||
|
;; Cursor movement
|
||||||
|
;;-----------------------------------------------
|
||||||
|
|
||||||
|
(def-completion-wrapper next-line :under-or-before)
|
||||||
|
(def-completion-wrapper previous-line :under-or-before)
|
||||||
|
(def-completion-wrapper beginning-of-buffer :under-or-before)
|
||||||
|
(def-completion-wrapper end-of-buffer :under-or-before)
|
||||||
|
(def-completion-wrapper beginning-of-line :under-or-before)
|
||||||
|
(def-completion-wrapper end-of-line :under-or-before)
|
||||||
|
(def-completion-wrapper forward-char :under-or-before)
|
||||||
|
(def-completion-wrapper forward-word :under-or-before)
|
||||||
|
(def-completion-wrapper forward-sexp :under-or-before)
|
||||||
|
(def-completion-wrapper backward-char :backward-under)
|
||||||
|
(def-completion-wrapper backward-word :backward-under)
|
||||||
|
(def-completion-wrapper backward-sexp :backward-under)
|
||||||
|
|
||||||
|
(def-completion-wrapper delete-backward-char :backward)
|
||||||
|
(def-completion-wrapper delete-backward-char-untabify :backward)
|
||||||
|
|
||||||
|
;; Tests --
|
||||||
|
;; foobarbiz
|
||||||
|
;; foobar
|
||||||
|
;; fooquux
|
||||||
|
;; fooper
|
||||||
|
|
||||||
|
(cmpl-statistics-block
|
||||||
(record-completion-file-loaded))
|
(record-completion-file-loaded))
|
||||||
|
|
||||||
|
(initialize-completions))
|
||||||
|
|
||||||
(provide 'completion)
|
(provide 'completion)
|
||||||
|
|
||||||
;;; completion.el ends here
|
;;; completion.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue