chiark / gitweb /
dot-emacs: Squash complaints about use of interactive commands.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 4 Apr 2008 20:09:19 +0000 (21:09 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 4 Apr 2008 20:09:19 +0000 (21:09 +0100)
The Emacs 22 byte compiler (at least) moans about me using replace-regexp
and insert-file.  So use (respectively) re-search-forward/replace-match
and insert-file-contents.

I think this change also fixes a bug in mdw-config which failed to
transform half of the config-file entries.

dot-emacs.el

index abf6dcc26d324cd7a0934a0f7082506a800c19fe..0f7cc5d16241e9d41824ceee3dce95ffbe16c813 100644 (file)
@@ -69,19 +69,22 @@ (defvar mdw-config nil)
 (defun mdw-config (sym)
   "Read the configuration variable named SYM."
   (unless mdw-config
-    (setq mdw-config (with-temp-buffer
-                      (insert-file-contents "~/.mdw.conf")
-                      (replace-regexp "^[ \t]*\\(#.*\\|\\)\n" ""
-                                      nil (point-min) (point-max))
-                      (replace-regexp (concat "^[ \t]*"
-                                              "\\([-a-zA-Z0-9_.]*\\)"
-                                              "[ \t]*=[ \t]*"
-                                              "\\(.*[^ \t\n]\\|\\)"
-                                              "[ \t]**\\(\n\\|$\\)")
-                                      "(\\1 . \"\\2\") "
-                                      nil (point-min) (point-max))
-                      (car (read-from-string
-                            (concat "(" (buffer-string) ")"))))))
+    (setq mdw-config
+         (flet ((replace (what with)
+                  (goto-char (point-min))
+                  (while (re-search-forward what nil t)
+                    (replace-match with t))))
+           (with-temp-buffer
+             (insert-file-contents "~/.mdw.conf")
+             (replace  "^[ \t]*\\(#.*\\|\\)\n" "")
+             (replace (concat "^[ \t]*"
+                              "\\([-a-zA-Z0-9_.]*\\)"
+                              "[ \t]*=[ \t]*"
+                              "\\(.*[^ \t\n]\\|\\)"
+                              "[ \t]**\\(\n\\|$\\)")
+                      "(\\1 . \"\\2\")\n")
+             (car (read-from-string
+                   (concat "(" (buffer-string) ")")))))))
   (cdr (assq sym mdw-config)))
 
 ;; --- Is an Emacs library available? ---
@@ -287,7 +290,7 @@ (defun np (&optional arg)
     (or arg (progn
              (goto-char (point-max))
              (insert "\nNP: ")
-             (insert-file np-file)))))
+             (insert-file-contents np-file)))))
 
 (defun mdw-check-autorevert ()
   "Sets global-auto-revert-ignore-buffer appropriately for this buffer,