Thursday, May 24, 2012

A Couple of Emacs Tips

Getting crushed at work....which makes me even more lazier at this.

First, if you want to run different .emacs based on the version of Emacs,  suggestions are provided here and here with an outline of how to do it.

Second, if you're particular about how and where the Emacs app should start on your screen, here's one way of doing it.

Props to original posters for the answers.

1 comment:

Phil Hudson said...

;; Create a macro for conditionally compiling code specific to each
;; emacs version, OS and host you use.

(defconst ph/emacs-versions '(21 22 23))
(defconst ph/obsolete-hosts '("kamanev" "PHC" "PBG3" "VMint" "Tlou" "Phil-Hudsons-Computer"))
(defconst ph/hosts `("MBP" "VUbuntu" "quiz" "stone" "TiPB" ,@ph/obsolete-hosts))
(defconst ph/oses '(darwin gnu/linux cygwin))

;; Creates macros like "compile-if-emacs-version-22"
(dolist (ph/emacs-version ph/emacs-versions)
`(defmacro ,(intern (format "compile-if-emacs-version-%s" ph/emacs-version)) (&rest forms)
,(format "Conditionally compiles FORMS only under version %s." ph/emacs-version)
(when ,(eq emacs-major-version ph/emacs-version) `(progn ,@forms)))))

;; Creates macros like "compile-on-MBP"
(dolist (ph/host ph/hosts)
`(defmacro ,(intern (concat "compile-on-" ph/host)) (&rest forms)
,(format "Conditionally compiles FORMS only on %s.

References: `ph/short-host'" ph/host)
(when ,(string= ph/short-host ph/host) `(progn ,@forms)))))

;; Creates macros like "compile-on-darwin"
(dolist (os ph/oses)
(let ((os-name (symbol-name os)))
`(defmacro ,(intern (concat "compile-on-" os-name)) (&rest forms)
,(format "Conditionally compiles FORMS only on %s." os-name)
(when ,(eq system-type os) `(progn ,@forms))))))