[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
backquote - old style
backquote - old style
26 Nov 2001 13:35:08 -0500
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1.50
My pet peeve with the elisp files in Emacs is old-style backquote.
(I wrote the appended code in 1999.)
RMS and Gerd after him postponed the fix until 21.1 was out.
May I go over the *.el files and change them?
My rationale is that the old-style backquote is hard to implement in a
CL, so the files with the old-style backquote are hard to load into a
CL (I have code to load emacs-lisp into common-lisp).
Sam Steingold (http://www.podval.org/~sds)
Keep Jerusalem united! <http://www.onejerusalem.org/Petition.asp>
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
A year spent in artificial intelligence is enough to make one believe in God.
;; File: <fix-bq.el - 1999-02-23 Tue 15:30:13 EST address@hidden>
;; Fix the old-style emacs backqoute
;; Copyright (C) 1999 Sam Steingold; GNU GPL-2 is applicable.
;; set `fix-backquote-patch-file' and `fix-backquote-auto' to your taste
;; (which usually means (setq fix-backquote-auto t) for directories and
;; (setq fix-backquote-auto nil) for files.)
(eval-when-compile (require 'cl))
(defvar fix-backquote-patch-file "/usr/local/src/patches/emacs-backquote.diff"
"The backquote diff file or nil.")
(defvar fix-backquote-auto nil
(defun fix-backquote-ask (prompt)
"Possibly ask a question, depending on `fix-backquote-auto'."
(or fix-backquote-auto (y-or-n-p prompt)))
(defun fix-backquote-dir (dir)
"Fix all files in the directory."
(interactive "DWhich directory to fix: ")
(when (and fix-backquote-patch-file
(let ((enable-local-variables nil) (find-file-hooks nil)
(global-font-lock-mode nil) (write-file-hooks nil))
(with-output-to-temp-buffer "fix backquote log"
(princ (format-time-string "fix-backquote-dir started: %Y-%m-%d %T\n"))
(labels ((fbd (dd)
(princ (format " -dir-> %s\n" dd))
(dolist (ff (directory-files dd t))
(if (and (not (string-match "/\\.\\.$" ff))
(not (string-match "/\\.$" ff))
(when (string-match "\\.el$" ff)
(princ (format " -file-> %s [%s]\n" ff
(if (fix-backquote-file ff)
(princ (format-time-string "fix-backquote-dir done: %Y-%m-%d %T\n")))))
(defun fix-backquote-in-the-code-p ()
"Check whether we are in the code - not comment or string.
(and (not (looking-at "[ ]*\""))
(not (looking-at "[ ]*;")))))
(defun fix-backquote-file (file)
"Fix everything in the file.
Returns t if the file was modifies, nil otherwise."
(interactive "fWhich file to fix: ")
(message "fix-backquote-file: %s" file)
(let ((buf (find-file-noselect file t t)))
(setq buffer-read-only nil)
(while (re-search-forward "(`[ \n]+" nil t)
(when (and (fix-backquote-in-the-code-p)
(fix-backquote-ask "ix this instance? "))
(cond ((buffer-modified-p buf)
(cond ((fix-backquote-ask "Create the diff file? ")
(copy-file file (concat file ".old") t t)
(shell-command (format "diff -cwb %s.old %s >> %s" file
(when (fix-backquote-ask "Kill buffer? ")
(t (kill-buffer buf)
(defun fix-backquote-defun ()
"Fix the current defun."
(fix-backquote-sexp "(`[ \n]+" "`")
(fix-backquote-sexp "(,@[ \n]+" ",@")
(fix-backquote-sexp "(,[ \n]+" ",")
(defun fix-backquote-sexp (str1 str2)
"Remove parens and spaces."
(while (re-search-forward str1 nil t)
(t (forward-line 1)))))
- backquote - old style,
Sam Steingold <=