[Top][All Lists]

[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


You might use this simple functions:

;;; ================================================================
;;; Static line number
;;; ================================================================

;;; From:!topic/

(defvar jd-static-line-number-regexp "(jd-static-line-number \\([0-9]*\\))")

(defun jd-static-line-number (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)."
      (goto-char (point-min))
      (while (re-search-forward jd-static-line-number-regexp (not 'bound) 
        (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 
         (message "BEG Running block at line %S..." ,line)
         (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!")) 

  (message "one...") 
  (jd-with-eval-after-load "org" (jd-static-line-number 0) (message "greetings 
  (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 

And then M-x jd-static-line-renumber RET in this buffer 
before evaluating/saving/loading the file.



reply via email to

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