emacs-devel
[Top][All Lists]
Advanced

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

Re: ;; -*-coding: emacs-mule;-*- ???


From: Sacha Chua
Subject: Re: ;; -*-coding: emacs-mule;-*- ???
Date: Mon, 03 Nov 2003 22:22:28 +0800
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Stefan Reich.ANvr <address@hidden> writes:

> Today I upgraded to the latest cvs version of emacs.
> Now I get the unwanted behaviour, that emacs inserts the following
> cookie in many files I want to save:
> ;; -*-coding: emacs-mule;-*-

I noticed that local-write-file-hooks (which is supposed to be
automatically buffer-local) gets globally modified when it's
add-hooked. This interacts badly with BBDB because BBDB 
addsbbdb-write-file-hook-fn to local-write-file-hooks, and then this
becomes a global hook. Here's the code responsible for inserting the
cookie.

    (unless (looking-at ";; *-\\*-coding:")
      (insert-before-markers (format ";; -*-coding: %s;-*-\n"
                     bbdb-file-coding-system))))

I've written a small test script to check. If everything worked
properly, this should not produce errors. On my system (emacs -q
--no-site-file, Emacs 21.3.50), it passes the
local-variable-that-works test, but fails the local-write-file-hooks
test. I suspect that obsolete permanently local variables are not
treated as permanently local when add-hook is used.

The workaround I use is

;; Run the offending function so that the records are loaded
(bbdb-records)
;; Restore my local write file hooks to nil
(setq-default local-write-file-hooks nil)   

Here's the test script:

(progn
  (defvar local-variable-that-works nil)
  (setq local-variable-that-works nil)
  (make-variable-buffer-local 'local-variable-that-works)
  (setq-default local-write-file-hooks nil)
  (with-temp-buffer (add-hook 'local-write-file-hooks 'foo)
                    (add-hook 'local-variable-that-works 'foo))
  (when local-variable-that-works
    (error "Failed test. Even the local variable that was supposed to work was 
modified."))
  (when local-write-file-hooks
    (error "Failed test. local-write-file-hooks was modified in this buffer. 
Perhaps obsolete buffer-local variables aren't buffer-local when add-hooked?")))

Hope that helps!
-- 
Sacha Chua <address@hidden> - Ateneo CS faculty geekette
interests: emacs, gnu/linux, wearables, teaching compsci
http://sacha.free.net.ph/




reply via email to

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