From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: Line number where eval-after-load is defined in my .emacs file Date: Thu, 14 Nov 2013 09:19:40 +0100 Message-ID: <87iovv5rab.fsf@zigzag.favinet> References: <86mwl88d9a.fsf@somewhere.org> <867gccnjrl.fsf@somewhere.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1384418421 29345 80.91.229.3 (14 Nov 2013 08:40:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Nov 2013 08:40:21 +0000 (UTC) Cc: public-help-gnu-emacs-mXXj517/zsQ@plane.gmane.org To: "Sebastien Vauban" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 14 09:40:23 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 1VgsTK-00069e-8S for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Nov 2013 09:40:18 +0100 Original-Received: from localhost ([::1]:54170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgsTJ-0003Sf-UP for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Nov 2013 03:40:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgsSx-0003Qa-7M for help-gnu-emacs@gnu.org; Thu, 14 Nov 2013 03:40:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgsSo-0002yR-Mp for help-gnu-emacs@gnu.org; Thu, 14 Nov 2013 03:39:55 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:53172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgsSo-0002yD-G3 for help-gnu-emacs@gnu.org; Thu, 14 Nov 2013 03:39:46 -0500 Original-Received: from public by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VgsSn-0005Z4-0T for help-gnu-emacs@gnu.org; Thu, 14 Nov 2013 09:39:45 +0100 Original-Received: from public by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VgsSg-0005VE-Tu for public-help-gnu-emacs-mXXj517/zsQ@plane.gmane.org; Thu, 14 Nov 2013 09:39:38 +0100 Original-Received: from smtp209.alice.it ([82.57.200.105]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vgs67-0005Wm-LW; Thu, 14 Nov 2013 09:16:20 +0100 Original-Received: from zigzag.favinet (79.40.74.32) by smtp209.alice.it (8.6.060.28) id 52443BB00B2C5869; Thu, 14 Nov 2013 09:16:10 +0100 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1Vgs9Y-0004fC-45; Thu, 14 Nov 2013 09:19:52 +0100 In-Reply-To: <867gccnjrl.fsf@somewhere.org> (Sebastien Vauban's message of "Wed, 13 Nov 2013 21:12:30 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-TMDA-Confirmed: Thu, 14 Nov 2013 09:39:38 +0100 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.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@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94488 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain () "Sebastien Vauban" () Wed, 13 Nov 2013 21:12:30 +0100 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: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=know-this.el Content-Transfer-Encoding: quoted-printable (defmacro know-this (&rest body) `(let ((loc (when (bufferp standard-input) (with-current-buffer standard-input (save-excursion (forward-sexp -1) (when (search-forward "(know-this" nil t) (1+ (count-lines (point-min) (match-beginning 0))))))))) (progn (message "=02 %S" loc) ,@body (message "=05")))) (know-this (message "???")) (progn (message "AAAAAA") (know-this (message "greetings earthlings")) (message "BBBBBB") (know-this (message "that's all for now")) (message "CCCCCC")) (know-this (message "!!!")) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 examine= the *Messages* buffer. =2D-=20 Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) =3D> nil --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlKEh6AACgkQZwMiJEyAdQJCPwCg1bv1y1aRQEz+MFqyeVenTkul 2DAAnRmKBli8j55PyWYEeOJx8mxHHuvX =CYxl -----END PGP SIGNATURE----- --==-=-=--