* searching file from emacs
@ 2008-02-14 23:41 marcmj
2008-02-15 5:25 ` Jonathan Rockway
0 siblings, 1 reply; 4+ messages in thread
From: marcmj @ 2008-02-14 23:41 UTC (permalink / raw)
To: Emacs-devel
Hello,
I am new to lisp and I want to make the following:
- in a emacs window, editing a routine, I locate the cursor in front or in
the middle of a routine name
- the macro will look for the entire name, then find the file in a given
list of directory
- once found, the macro will open the routine in the same emacs window
So if I have the source example.f where I have the following line:
call other_routine(a, b)
I would like to place the cursor on "other_routine" (anywhere in this
routine name) then hit a key and the code will search for other_routine.f in
a set of pre-defined directories, then open other_routine.f in the emacs
window.
So if anyone has some starting LISP code for this or may be able to help,
I'll appreciate !
Thanks
Marc
--
View this message in context: http://www.nabble.com/searching-file-from-emacs-tp15491987p15491987.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: searching file from emacs
2008-02-14 23:41 searching file from emacs marcmj
@ 2008-02-15 5:25 ` Jonathan Rockway
2008-02-15 15:53 ` marcmj
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Rockway @ 2008-02-15 5:25 UTC (permalink / raw)
To: marcmj; +Cc: Emacs-devel
* On Thu, Feb 14 2008, marcmj wrote:
> So if I have the source example.f where I have the following line:
> call other_routine(a, b)
>
> I would like to place the cursor on "other_routine" (anywhere in this
> routine name) then hit a key and the code will search for other_routine.f in
> a set of pre-defined directories, then open other_routine.f in the emacs
> window.
This sounds a lot like `find-tag' in `etags.el'. You might want to read
that first. In fact, I'm pretty sure find-tag can do what you want to
do, as long as you run some code before find-tag that sets up the tags
table correctly and then visits it.
Someone on #emacs provided me with the following code the other day:
;;; Järneström Jonas <Jonas.Jarnestrom AT ki.ericsson.se>
;;; A smarter find-tag that automagically reruns etags when it cant
;;; find a requested item and then makes a new try to locate it.
(defadvice find-tag (around refresh-etags activate)
"Rerun etags and reload tags if tag not found and redo find-tag.
If buffer is modified, ask about save before running etags."
(let* ((extension (file-name-extension (buffer-file-name))))
(condition-case err
ad-do-it
(error (and (buffer-modified-p)
(not (ding))
(y-or-n-p "Buffer is modified, save it? ")
(save-buffer))
(er-refresh-etags extension)
ad-do-it))))
(defun er-refresh-etags (extension)
"Run etags on all peer files in current dir and reload them silently."
(interactive)
(when (not found-perl-tags)
(shell-command (format "etags *.%s" extension))
(let ((tags-revert-without-query t)) ; don't query, revert silently
(visit-tags-table default-directory nil))))
This tries to find a tag normally, then if that fails, it builds a tags
table and tries again. Basically, you'll probably want to modify this
to run a different command based on the major mode that you want this to
work in. I do this for cperl-mode buffers:
(shell-command (format "find %s | grep pm$ | etags - -o %s" root
tags))
`root' is the root of my project, `tags' is root/TAGS basically. I can
provide more detail if you need it.
Regards,
Jonathan Rockway
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: searching file from emacs
2008-02-15 5:25 ` Jonathan Rockway
@ 2008-02-15 15:53 ` marcmj
2008-02-15 18:12 ` Drew Adams
0 siblings, 1 reply; 4+ messages in thread
From: marcmj @ 2008-02-15 15:53 UTC (permalink / raw)
To: Emacs-devel
Yes, I can definitely use some more info.
Where do you locate this code in order to run it under emacs ? How to
trigger it ?
Thanks
--
View this message in context: http://www.nabble.com/searching-file-from-emacs-tp15491987p15502647.html
Sent from the Emacs - Dev mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: searching file from emacs
2008-02-15 15:53 ` marcmj
@ 2008-02-15 18:12 ` Drew Adams
0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2008-02-15 18:12 UTC (permalink / raw)
To: 'marcmj', Help-Gnu-Emacs; +Cc: Emacs-devel
> Yes, I can definitely use some more info.
> Where do you locate this code in order to run it under emacs ? How to
> trigger it ?
The Emacs manual is your friend. `C-h i', follow the `Emacs' link, then `g
tags'. Choose the menu item `Find Tag'.
FYI: A better mailing list for this kind of question is
help-gnu-emacs@gnu.org.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-02-15 18:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-14 23:41 searching file from emacs marcmj
2008-02-15 5:25 ` Jonathan Rockway
2008-02-15 15:53 ` marcmj
2008-02-15 18:12 ` Drew Adams
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.