[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Find tags with dot character
From: |
Pascal Quesseveur |
Subject: |
Re: Find tags with dot character |
Date: |
Tue, 23 Jul 2019 09:05:09 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
>"SM" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
SM> In case of an error (or a C-g) during the execution of find-tag-default,
SM> this will fail to restore the syntax-table to its original state, so
SM> I recommend:
SM> (defun my-find-tag-default-opascal ()
SM> (unwind-protect
SM> (progn (modify-syntax-entry ?. "w")
SM> (find-tag-default))
SM> (modify-syntax-entry ?. ".")))
OK.
> And in Delphi mode hook, I added:
>
> (setq find-tag-default-function 'my-find-tag-default-opascal)
SM> This likely affects the variable globally, so maybe you'd want
SM> to use `setq-local` instead.
Yes, thank you.
SM> Your approach above will make thing worse in several important
SM> use cases (e.g. when point is on "<var>.<method>" where we won't
SM> find that tag anywhere (we'd have to lookup something like
SM> "<class>.<method>" instead))
Yes, we need both.
SM> is by default, but I think we'd welcome patches which try to
SM> improve on this (e.g. by first trying with the dots and if that
SM> fails try again without them).
I'm afraid I'm not expert enough to propose a modification of etags,
either etags the program or the etags handling in emacs. In addition i
use an old version of emacs (24.3) for delphi devlopment, where I
don't have the new opascal mode, only delphi-mode. I still tried and
produced those functions:
(defun my-find-tag-opascal-helper (prompt)
"Helper to call find-tag and catch errors. I was unable to call
find-tag-interactive, so I used find-tag-tag without any
options."
(condition-case err
(let ((tagname (find-tag-tag prompt)))
(find-tag tagname)
t)
(error (message "%s" (error-message-string err))
nil)))
(defun my-find-tag-opascal()
"First call find-tag using current find-tag-default-function,
and when no tags are found call find-tag again with
find-tag-default-function set to nil."
(interactive)
(let ((xp (point))
(xb (current-buffer))
tfunc)
(unless (my-find-tag-opascal-helper "Find tag: ")
(set-buffer xb)
(goto-char xp)
(setq tfunc find-tag-default-function)
(setq-local find-tag-default-function nil)
(unwind-protect
(my-find-tag-opascal-helper "Tag not found. Retry with: ")
(set-buffer xb)
(setq-local find-tag-default-function tfunc)))))
--
Pascal Quesseveur
pquessev@gmail.com