emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find-tag-default


From: Juri Linkov
Subject: Re: find-tag-default
Date: Thu, 20 May 2004 11:09:48 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

I have a better idea: to left the function `find-tag-default'
alone in its etags.el, and to add a new function (which is
slightly extended version of `find-tag-default') to simple.el:

(defun identifier-at-point ()
  "Return a default identifier based on the text at point."
  (or (and (boundp 'find-tag-default-function)
           find-tag-default-function
           (funcall find-tag-default-function))
      (and (get major-mode 'find-tag-default-function)
           (funcall (get major-mode 'find-tag-default-function)))
      (save-excursion
        (while (looking-at "\\sw\\|\\s_")
          (forward-char 1))
        (when (or (re-search-backward "\\sw\\|\\s_"
                                      (save-excursion (beginning-of-line) 
(point))
                                      t)
                  (re-search-forward "\\(\\sw\\|\\s_\\)+"
                                     (save-excursion (end-of-line) (point))
                                     t))
          (goto-char (match-end 0))
          (buffer-substring-no-properties
           (point)
           (progn (forward-sexp -1)
                  (while (looking-at "\\s'")
                    (forward-char 1))
                  (point)))))))

There are several benefits:

1. no need to load etags.el;

2. a complicated construct

(funcall (or find-tag-default-function
         (get major-mode 'find-tag-default-function)
         'find-tag-default))

is replaced by a simple function call `(identifier-at-point)'.

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]