From: jack-mac <duthen.mac@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Line number where eval-after-load is defined in my .emacs file
Date: Fri, 22 Nov 2013 08:47:39 -0800 (PST) [thread overview]
Message-ID: <87b2f76b-8468-448a-8962-f62e0a3087e5@googlegroups.com> (raw)
In-Reply-To: <86mwl88d9a.fsf@somewhere.org>
Hello!
You might use this simple functions:
;;; ================================================================
;;; Static line number
;;; ================================================================
;;; From: https://groups.google.com/forum/#!topic/gnu.emacs.help/v1QdtBooy2k
(defvar jd-static-line-number-regexp "(jd-static-line-number \\([0-9]*\\))")
(defun jd-static-line-number (line-num)
line-num)
;;; If you type anywhere in a file (either in code or comments) come text like
;;; (jd-static-line-number X) ; where X is the character 0 (or any number)
;;; and if you type M-x jd-static-line-renumber RET while inside this buffer
;;; then the number in this text will automagically be transformed into the current line number!
;;; Like this:
;;; The current line number (in this line) is (jd-static-line-number 20)
(defun jd-static-line-renumber ()
"Replace with the current line number the number X appearing in each occurrence of (jd-static-line-number X)."
(interactive)
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(while (re-search-forward jd-static-line-number-regexp (not 'bound) 'noerror)
(replace-match (number-to-string (count-lines (point-min) (point)))
'fixed-case 'literal (not 'string) 1)))))
(defmacro jd-with-eval-after-load (file line &rest body)
`(eval-after-load ,file
'(progn
(message "BEG Running block at line %S..." ,line)
,@body
(message "END Running block at line %S..." ,line))))
Then, you put this into your file:
(jd-with-eval-after-load "org" (jd-static-line-number 0)
(message "Quite early!"))
(progn
(message "one...")
(jd-with-eval-after-load "org" (jd-static-line-number 0) (message "greetings earthlings"))
(message "two...")
(jd-with-eval-after-load "org" (jd-static-line-number 0) (message "that's all for now"))
(message "three..."))
(jd-with-eval-after-load "org" (jd-static-line-number 0) (message "Quite late?"))
And then M-x jd-static-line-renumber RET in this buffer
before evaluating/saving/loading the file.
HTH
)jack(
prev parent reply other threads:[~2013-11-22 16:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 16:42 Line number where eval-after-load is defined in my .emacs file Sebastien Vauban
2013-11-13 17:05 ` William G. Gardella
[not found] ` <mailman.5986.1384362332.10748.help-gnu-emacs@gnu.org>
2013-11-13 20:12 ` Sebastien Vauban
2013-11-14 8:19 ` Thien-Thi Nguyen
[not found] ` <mailman.6043.1384418405.10748.help-gnu-emacs@gnu.org>
2013-11-15 13:43 ` Sebastien Vauban
2013-11-16 1:40 ` Michael Heerdegen
2013-11-13 21:03 ` Sebastien Vauban
2013-11-13 22:09 ` Stefan Monnier
2013-11-13 23:26 ` Michael Heerdegen
[not found] ` <mailman.6018.1384385233.10748.help-gnu-emacs@gnu.org>
2013-11-15 13:46 ` Sebastien Vauban
2013-11-22 16:47 ` jack-mac [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87b2f76b-8468-448a-8962-f62e0a3087e5@googlegroups.com \
--to=duthen.mac@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).