help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need to unhook a function in Makefile-mode


From: jgombos
Subject: Need to unhook a function in Makefile-mode
Date: Mon, 29 Oct 2007 14:22:07 -0700 (PDT)

I have a C++ write file hook to automatically untabify the whole buffer
before saving.  It works great, but then when I open a Makefile in
Makefile-mode, the hook persists, which ruins Makefiles.  My .emacs file
contains:
<pre>
;; Define untabify-buffer.
(defun untabify-buffer()
  (interactive)
  "Untabify the current buffer.  Return nil.

  Must return nil, if added to write-file-hooks."
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "[ \t]+$" nil t)
      (delete-region (match-beginning 0) (match-end 0)))
    (goto-char (point-min))
    (if (search-forward "\t" nil t)
        (untabify (1- (point)) (point-max))))
  nil)

;; LANGUAGE HOOKS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'c++-mode-hook
          '(lambda ()
                  (c-set-style "whitesmith")
                  (add-hook 'write-file-hooks 'untabify-buffer)
                  ))
</pre>
http://www.emacswiki.org/cgi-bin/emacs-en/UntabifyUponSave This article 
suggests a solution, but someone responded to that saying that the
alternative approach screws up formatting (eg. number of spaces equated with
a tab).  And I don't want to untabify manually (even though tabs are
highlighted in my view).  

I would like a Makefile write hook that will undo the C++ write file hook. 
Perhaps I've been spoiled with Mutt's "unhook" feature.  [Mutt is an MUA
that has hook (and unhook) features in the configuration scripts].
-- 
View this message in context: 
http://www.nabble.com/Need-to-unhook-a-function-in-Makefile-mode-tf4714791.html#a13477295
Sent from the Emacs - Help mailing list archive at Nabble.com.





reply via email to

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