[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Line number where eval-after-load is defined in my .emacs file
From: |
Sebastien Vauban |
Subject: |
Re: Line number where eval-after-load is defined in my .emacs file |
Date: |
Fri, 15 Nov 2013 14:43:42 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) |
Hi Thien-Thi,
Thien-Thi Nguyen wrote:
> () "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
>
> So the question boils down to: is it possible to access/save the line
> number of where the macro is called (in my .emacs file)?
>
> Under some circumstances, yes. Here is a quick sketch:
>
> that demonstrates the basic technique, and illustrates the primary
> shortcomings -- unreliability and imprecision (if you use it, you will
> undoubtedly discover the other shortcomings, soon enough :-D).
>
> To play, save to disk, ‘M-x load-file’ it, and then examine the
> *Messages* buffer.
This looks quite close to what I'm looking for -- thanks!
However, when trying to adapt it with the `eval-after-load' form:
--8<---------------cut here---------------start------------->8---
(defmacro my-with-eval-after-load (file &rest body)
`(let ((loc (when (bufferp standard-input)
(with-current-buffer standard-input
(save-excursion
(forward-sexp -1)
(when (search-forward "(my-with-eval-after-load" nil t)
(1+ (count-lines (point-min)
(match-beginning 0)))))))))
(eval-after-load ,file
'(progn
(message "BEG Running block at line %S..."
,loc)
,@body
(message "END Running block at line %S..."
,loc)))))
(my-with-eval-after-load "org"
(message "Quite early!"))
(progn
(message "one...")
(my-with-eval-after-load "org" (message "greetings earthlings"))
(message "two...")
(my-with-eval-after-load "org" (message "that's all for now"))
(message "three..."))
(my-with-eval-after-load "org" (message "Quite late?"))
--8<---------------cut here---------------end--------------->8---
I do have the error:
cons: Symbol's value as variable is void: loc
when evaluating it... and I don't understand what I got wrong.
Best regards,
Seb
--
Sebastien Vauban
Re: Line number where eval-after-load is defined in my .emacs file, Sebastien Vauban, 2013/11/13
Re: Line number where eval-after-load is defined in my .emacs file, Michael Heerdegen, 2013/11/13
Message not available
Re: Line number where eval-after-load is defined in my .emacs file, jack-mac, 2013/11/22