From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Sebastien Vauban" Newsgroups: gmane.emacs.help Subject: Re: Line number where eval-after-load is defined in my .emacs file Date: Fri, 15 Nov 2013 14:43:42 +0100 Organization: Sebastien Vauban Message-ID: <86vbztsru9.fsf@somewhere.org> References: <86mwl88d9a.fsf@somewhere.org> <867gccnjrl.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1384523117 23077 80.91.229.3 (15 Nov 2013 13:45:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Nov 2013 13:45:17 +0000 (UTC) To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Fri Nov 15 14:45:22 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VhJi1-00070U-RW for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 14:45:18 +0100 Original-Received: from localhost ([::1]:60425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhJi1-0006VV-Go for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 08:45:17 -0500 Original-Path: usenet.stanford.edu!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 63 Injection-Info: mx05.eternal-september.org; posting-host="402b34550bd938aa98825778083dce0e"; logging-data="20883"; mail-complaints-to="abuse-VVbKFVtnif8H+i2N2EyTrmui9UKz+5OX@public.gmane.org"; posting-account="U2FsdGVkX1+HbAZx89rPBej43zHOQB6D" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Archive: encrypt Cancel-Lock: sha1:Ysg49KRYXb9SvlHc27ZB/cogKcc= sha1:tKQX8347LOfw4asyf8dmq10nhMA= X-Url: Under construction... Original-Xref: usenet.stanford.edu gnu.emacs.help:202227 X-BeenThere: help-gnu-emacs-mXXj517/zsQ@public.gmane.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org-mXXj517/zsQ@public.gmane.org Xref: news.gmane.org gmane.emacs.help:94496 Archived-At: Hi Thien-Thi, Thien-Thi Nguyen wrote: > () "Sebastien Vauban" > > 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, =E2=80=98M-x load-file=E2=80=99 it, and then exami= ne 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 --=20 Sebastien Vauban