comparison lisp/progmodes/etags.el @ 108179:8bcf1c901e9a

* minibuffer.el (tags-completion-at-point-function): Move to etags.el. * progmodes/etags.el (tags-completion-at-point-function): Remove left over interactive spec. Add autoloading stub. (complete-tag): Use tags-completion-at-point-function.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 30 Apr 2010 21:08:43 -0400
parents 15deb8699a13
children de5d6a3f1493
comparison
equal deleted inserted replaced
108178:0f3897ef1f44 108179:8bcf1c901e9a
421 Sets the current buffer to one visiting FILE (if it exists). 421 Sets the current buffer to one visiting FILE (if it exists).
422 Returns non-nil if it is a valid table." 422 Returns non-nil if it is a valid table."
423 (if (get-file-buffer file) 423 (if (get-file-buffer file)
424 ;; The file is already in a buffer. Check for the visited file 424 ;; The file is already in a buffer. Check for the visited file
425 ;; having changed since we last used it. 425 ;; having changed since we last used it.
426 (let (win) 426 (progn
427 (set-buffer (get-file-buffer file)) 427 (set-buffer (get-file-buffer file))
428 (setq win (or verify-tags-table-function (tags-table-mode))) 428 (or verify-tags-table-function (tags-table-mode))
429 (if (or (verify-visited-file-modtime (current-buffer)) 429 (if (or (verify-visited-file-modtime (current-buffer))
430 ;; Decide whether to revert the file. 430 ;; Decide whether to revert the file.
431 ;; revert-without-query can say to revert 431 ;; revert-without-query can say to revert
432 ;; or the user can say to revert. 432 ;; or the user can say to revert.
433 (not (or (let ((tail revert-without-query) 433 (not (or (let ((tail revert-without-query)
785 (save-excursion 785 (save-excursion
786 ;; If we need to ask for the tag table, allow that. 786 ;; If we need to ask for the tag table, allow that.
787 (let ((enable-recursive-minibuffers t)) 787 (let ((enable-recursive-minibuffers t))
788 (visit-tags-table-buffer)) 788 (visit-tags-table-buffer))
789 (complete-with-action action (tags-completion-table) string pred)))))) 789 (complete-with-action action (tags-completion-table) string pred))))))
790
791 ;;;###autoload (defun tags-completion-at-point-function ()
792 ;;;###autoload (if (or tags-table-list tags-file-name)
793 ;;;###autoload (progn
794 ;;;###autoload (load "etags")
795 ;;;###autoload (tags-completion-at-point-function))))
796
797 (defun tags-completion-at-point-function ()
798 "Using tags, return a completion table for the text around point.
799 If no tags table is loaded, do nothing and return nil."
800 (when (or tags-table-list tags-file-name)
801 (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
802 tags-case-fold-search
803 case-fold-search))
804 (pattern (funcall (or find-tag-default-function
805 (get major-mode 'find-tag-default-function)
806 'find-tag-default)))
807 beg)
808 (when pattern
809 (save-excursion
810 (search-backward pattern) ;FIXME: will fail if we're inside pattern.
811 (setq beg (point))
812 (forward-char (length pattern))
813 (list beg (point) (tags-lazy-completion-table)))))))
790 814
791 (defun find-tag-tag (string) 815 (defun find-tag-tag (string)
792 "Read a tag name, with defaulting and completion." 816 "Read a tag name, with defaulting and completion."
793 (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) 817 (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
794 tags-case-fold-search 818 tags-case-fold-search
2037 (or tags-table-list 2061 (or tags-table-list
2038 tags-file-name 2062 tags-file-name
2039 (error "%s" 2063 (error "%s"
2040 (substitute-command-keys 2064 (substitute-command-keys
2041 "No tags table loaded; try \\[visit-tags-table]"))) 2065 "No tags table loaded; try \\[visit-tags-table]")))
2042 (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil)) 2066 (let ((comp-data (tags-completion-at-point-function)))
2043 tags-case-fold-search 2067 (if (null comp-data)
2044 case-fold-search)) 2068 (error "Nothing to complete")
2045 (pattern (funcall (or find-tag-default-function 2069 (apply 'completion-in-region comp-data))))
2046 (get major-mode 'find-tag-default-function)
2047 'find-tag-default)))
2048 (comp-table (tags-lazy-completion-table))
2049 beg)
2050 (or pattern
2051 (error "Nothing to complete"))
2052 (search-backward pattern)
2053 (setq beg (point))
2054 (forward-char (length pattern))
2055 (completion-in-region beg (point) comp-table)))
2056 2070
2057 (dolist (x '("^No tags table in use; use .* to select one$" 2071 (dolist (x '("^No tags table in use; use .* to select one$"
2058 "^There is no default tag$" 2072 "^There is no default tag$"
2059 "^No previous tag locations$" 2073 "^No previous tag locations$"
2060 "^File .* is not a valid tags table$" 2074 "^File .* is not a valid tags table$"