[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: |
jack-mac |
Subject: |
Re: Line number where eval-after-load is defined in my .emacs file |
Date: |
Fri, 22 Nov 2013 08:47:39 -0800 (PST) |
User-agent: |
G2/1.0 |
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(
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 <=