From 7037511be8149af0882ce483fc00c8c71acee4ef Mon Sep 17 00:00:00 2001 From: "Michael W. Olson" Date: Thu, 23 Aug 2007 22:08:39 -0400 Subject: [PATCH] Fix bug with using different muse-file-extension * lisp/muse.el (muse-update-file-extension): Simplify, and handle some edge cases. (muse-update-file-extension-after-init): Temporarily bind muse-file-extension to "muse", so that muse-update-file-extension knows what the old value was. This should fix a bug reported by Jean Magnan de Bornier. --- ChangeLog | 7 +++++++ lisp/muse.el | 51 +++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d14176..1e9ca09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,13 @@ * lisp/muse-publish.el (muse-publish-markup-heading): Don't escape specials here. This fixes a bug involving links in headings. + * lisp/muse.el (muse-update-file-extension): Simplify, and handle + some edge cases. + (muse-update-file-extension-after-init): Temporarily bind + muse-file-extension to "muse", so that muse-update-file-extension + knows what the old value was. This should fix a bug reported by + Jean Magnan de Bornier. + 2007-08-21 Michael Olson * lisp/muse-texinfo.el (muse-texinfo-markup-strings): Try to make diff --git a/lisp/muse.el b/lisp/muse.el index 3b8962f..92b0eb2 100644 --- a/lisp/muse.el +++ b/lisp/muse.el @@ -98,31 +98,27 @@ This is autogenerated from `muse-ignored-extensions'.") (defun muse-update-file-extension (sym val) "Update the value of `muse-file-extension'." - (when (and (featurep 'muse-mode) - (boundp sym) (stringp (symbol-value sym)) - (or (not (stringp val)) - (not (string= (symbol-value sym) val)))) - ;; remove old auto-mode-alist association - (setq auto-mode-alist - (delete (cons (concat "\\." (symbol-value sym) "\\'") - 'muse-mode-choose-mode) - auto-mode-alist))) - (set sym val) - ;; associate the new file extension with muse-mode - (when (and (featurep 'muse-mode) - (stringp val) - (or (not (stringp (symbol-value sym))) - (not (string= (symbol-value sym) val)))) - (add-to-list 'auto-mode-alist - (cons (concat "\\." val "\\'") - 'muse-mode-choose-mode))) - ;; update the ignored extensions regexp - (when (and (fboundp 'muse-update-ignored-extensions-regexp) - (or (not (stringp (symbol-value sym))) - (not (stringp val)) - (not (string= (symbol-value sym) val)))) - (muse-update-ignored-extensions-regexp - 'muse-ignored-extensions muse-ignored-extensions))) + (let ((old (and (boundp sym) (symbol-value sym)))) + (set sym val) + (when (and (featurep 'muse-mode) + (or (not (stringp val)) + (not (stringp old)) + (not (string= old val)))) + ;; remove old auto-mode-alist association + (when (and (boundp sym) (stringp old)) + (setq auto-mode-alist + (delete (cons (concat "\\." old "\\'") + 'muse-mode-choose-mode) + auto-mode-alist))) + ;; associate the new file extension with muse-mode + (when (stringp val) + (add-to-list 'auto-mode-alist + (cons (concat "\\." val "\\'") + 'muse-mode-choose-mode))) + ;; update the ignored extensions regexp + (when (fboundp 'muse-update-ignored-extensions-regexp) + (muse-update-ignored-extensions-regexp + 'muse-ignored-extensions muse-ignored-extensions))))) (defcustom muse-file-extension "muse" "File extension of Muse files. Omit the period at the beginning. @@ -171,7 +167,10 @@ understand that it is part of a regexp." (defun muse-update-file-extension-after-init () ;; This is short, but it has to be a function, otherwise Emacs21 ;; does not load it properly when running after-init-hook - (muse-update-file-extension 'muse-file-extension muse-file-extension)) + (unless (string= muse-file-extension "muse") + (let ((val muse-file-extension) + (muse-file-extension "muse")) + (muse-update-file-extension 'muse-file-extension val)))) ;; Once the user's init file has been processed, determine whether ;; they want a file extension -- 2.11.4.GIT