chiark / gitweb /
Merge branch 'master' of git.distorted.org.uk:~mdw/public-git/profile
authorMark Wooding <mdw@distorted.org.uk>
Mon, 31 Dec 2012 05:32:58 +0000 (05:32 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 31 Dec 2012 05:32:58 +0000 (05:32 +0000)
* 'master' of git.distorted.org.uk:~mdw/public-git/profile:
  el/dot-emacs.el: Respect `indent-tabs-mode' when computing fill prefix.
  el/dot-emacs.el: Use #'FOO rather than (function FOO).
  dot/emacs: Use `makefile-mode' for *.make files.

dot/emacs
el/dot-emacs.el

index ceef41422cc936ac325c3904e7ea9ee93002f7be..20daa9b0818a2907a0c766ee1d14d1adf226749d 100644 (file)
--- a/dot/emacs
+++ b/dot/emacs
                ("\\.cs$" . csharp-mode)
                ("\\.go$" . go-mode)
                ("\\.org$" . org-mode)
+               ("\\.make$" . makefile-mode)
                ;; ("/[ch]/" . c-mode)
                (,(concat "/\\("
                          "\\.stgit\\.msg" "\\|"
index 20978ded96ecf15b75f4a69cd08db82dbf110bd9..2909fdd67da388047d2e61635922e86f610bfa8d 100644 (file)
@@ -645,21 +645,15 @@ (fset 'mdw-do-auto-fill (symbol-function 'do-auto-fill))
 
 ;; Utility functions.
 
-(defun mdw-tabify (s)
-  "Tabify the string S.  This is a horrid hack."
-  (save-excursion
+(defun mdw-maybe-tabify (s)
+  "Tabify or untabify the string S, according to `indent-tabs-mode'."
+  (with-temp-buffer
     (save-match-data
-      (let (start end)
-       (beginning-of-line)
-       (setq start (point-marker))
+      (let ((tabfun (if indent-tabs-mode #'tabify #'untabify)))
        (insert s "\n")
-       (setq end (point-marker))
-       (tabify start end)
-       (setq s (buffer-substring start (1- end)))
-       (delete-region start end)
-       (set-marker start nil)
-       (set-marker end nil)
-       s))))
+       (let ((start (point-min)) (end (point-max)))
+         (funcall tabfun start end)
+         (setq s (buffer-substring start (1- end))))))))
 
 (defun mdw-examine-fill-prefixes (l)
   "Given a list of dynamic fill prefixes, pick one which matches
@@ -667,9 +661,9 @@ (defun mdw-examine-fill-prefixes (l)
 at the start of a line, and match data must be saved."
   (cond ((not l) nil)
               ((looking-at (car (car l)))
-               (mdw-tabify (apply (function concat)
-                                  (mapcar (function mdw-do-prefix-match)
-                                          (cdr (car l))))))
+               (mdw-maybe-tabify (apply #'concat
+                                        (mapcar #'mdw-do-prefix-match
+                                                (cdr (car l))))))
               (t (mdw-examine-fill-prefixes (cdr l)))))
 
 (defun mdw-maybe-car (p)