help-gnu-emacs
[Top][All Lists]
Advanced

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

Line number where eval-after-load is defined in my .emacs file


From: Sebastien Vauban
Subject: Line number where eval-after-load is defined in my .emacs file
Date: Wed, 13 Nov 2013 17:42:09 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Hello,

As I do (sometimes) have -- for the same library -- multiple "eval-after-load"
blocks of code at different spots of my .emacs file, I'd like to be able to
identify which one was called at which point when reading the Messages buffer.

To do so, I tried to (re-)define `with-eval-after-load' such as:

--8<---------------cut here---------------start------------->8---
  ;; wrapper around `eval-after-load'
  (defmacro with-eval-after-load (mode &rest body)
    "`eval-after-load' MODE evaluate BODY."
    (declare (indent defun))
    `(eval-after-load ,mode
       '(progn
          (message "<<< Running code block specific to library `%s' (at line 
%d)..."
                   ,mode
                   ,(org-current-line)) ; [1]
          ,@body
          (message ">>>"))))
--8<---------------cut here---------------end--------------->8---

I'd like to see:

--8<---------------cut here---------------start------------->8---
<<< Running code block specific to library `org' (at line 123)...
...
>>>
<<< Running code block specific to library `org' (at line 567)...
...
>>>
--8<---------------cut here---------------end--------------->8---

It works well, except that line is always displayed as `1' in the Messages
buffer.

Is there a way to "link" the messages to the `eval-after-load' blocks in my
.emacs file by showing the line number where those blocks are defined?

Or is there some other way to get such more or less the same type of
information?

Best regards,
  Seb

[1] The code for org-current-line is:

--8<---------------cut here---------------start------------->8---
  (defsubst org-current-line (&optional pos)
    (save-excursion
      (and pos (goto-char pos))
      ;; works also in narrowed buffer, because we start at 1, not point-min
      (+ (if (bolp) 1 0) (count-lines 1 (point)))))
--8<---------------cut here---------------end--------------->8---

-- 
Sebastien Vauban


reply via email to

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