[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Command line open does not use find-file anymore?
From: |
Everton J. Carpes |
Subject: |
Command line open does not use find-file anymore? |
Date: |
Mon, 18 Sep 2017 06:00:16 -0300 |
Until emacs 24 I was able to customize file opening using an "advice"
around find-file. It was working for opening from inside emacs and also
from command line.
I use this to deal with common error reports, which are presented in
"filename:lineno" syntax. The suggestion to do this can be found here:
>
https://stackoverflow.com/questions/3139970/open-a-file-at-line-with-filenameline-syntax
After updating to version 25 (actually 25.2.2) and follow the instructions
to update advice which I found here:
>
https://www.gnu.org/software/emacs/manual/html_node/elisp/Porting-old-advice.html
The around is working when find-file is called from inside emacs, but not
when emacs is called from command line.
1. Emacs 25 doesn't use find-file anymore when opening from command line?
2. Which function is called now?
3. Is this the best way to deal with this kind of customization?
4. How can I learn more about what emacs does when opened?
I spect this is the proper mailing list to post this question. If not,
really sorry and I appreciate instructions about where and how to post this.
Thanks for your time.
P.S.: Just for reference, the code I'm using (the same posted on SO), after
update it into the new advice syntax is:
(defun find-file--line-number (orig-fun filename &optional wildcards)
"Turn files like file.cpp:14 into file.cpp and going to the 14-th line."
(save-match-data
(let* ((matched (string-match "^\\(.*\\):\\([0-9]+\\):?$" filename))
(line-number (and matched
(match-string 2 filename)
(string-to-number (match-string 2 filename))))
(filename (if matched (match-string 1 filename) filename)))
(apply orig-fun (list filename wildcards))
(when line-number
;; goto-line is for interactive use
(goto-char (point-min))
(forward-line (1- line-number))))))
(advice-add 'find-file :around #'find-file--line-number)
--
Everton J. Carpes
- Command line open does not use find-file anymore?,
Everton J. Carpes <=