all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stuart D. Herring" <herring@lanl.gov>
Cc: michael.cadilhac@lrde.org, emacs-devel@gnu.org
Subject: Re: Mode loaded twice with Local Variables
Date: Wed, 10 May 2006 11:20:33 -0700 (PDT)	[thread overview]
Message-ID: <56383.128.165.123.132.1147285233.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <E1FdspO-0006SH-NJ@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

> 					What if the major mode was itself an
>     alias, or does that not happen?
>
> It could, so the code should do indirect-function on both of them
> and compare the results.

OK; the attached (tiny) patch does that in both places.  This makes the
change that `set-auto-mode-0' now returns its MODE argument instead of the
final symbol (which has the real function definition) in that argument's
indirect function chain.  Nothing seems to use the return value anyway;
does this matter?  If so, I can write the symbol-chasing loop back in to
get the old return value.

Davis

2006-05-10  Stuart Herring  <herring@lanl.gov>

	* files.el (set-auto-mode-0): Use `indirect-function'.
	(hack-one-local-variable): Don't reapply the current major mode.

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.

[-- Attachment #2: mode-reapply.patch --]
[-- Type: application/octet-stream, Size: 1861 bytes --]

Index: files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.831
diff -c -r1.831 files.el
*** files.el	9 May 2006 22:55:30 -0000	1.831
--- files.el	10 May 2006 18:10:15 -0000
***************
*** 2192,2203 ****
  If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of
  any aliases and compared to current major mode.  If they are the
  same, do nothing and return nil."
!   (when keep-mode-if-same
!     (while (symbolp (symbol-function mode))
!       (setq mode (symbol-function mode)))
!     (if (eq mode major-mode)
! 	(setq mode nil)))
!   (when mode
      (funcall mode)
      mode))
  
--- 2192,2199 ----
  If optional arg KEEP-MODE-IF-SAME is non-nil, MODE is chased of
  any aliases and compared to current major mode.  If they are the
  same, do nothing and return nil."
!   (unless (and keep-mode-if-same
! 	       (eq (indirect-function mode) (indirect-function major-mode)))
      (funcall mode)
      mode))
  
***************
*** 2722,2731 ****
  		      ok)))))))
  
  (defun hack-one-local-variable (var val)
!   "Set local variable VAR with value VAL."
    (cond ((eq var 'mode)
! 	 (funcall (intern (concat (downcase (symbol-name val))
! 				  "-mode"))))
  	((eq var 'eval)
  	 (save-excursion (eval val)))
  	(t (make-local-variable var)
--- 2733,2745 ----
  		      ok)))))))
  
  (defun hack-one-local-variable (var val)
!   "Set local variable VAR with value VAL.
! If VAR is `mode', call `VAL-mode' as a
! function unless it's already the major mode."
    (cond ((eq var 'mode)
! 	 (let ((mode (intern (concat (downcase (symbol-name val)) "-mode"))))
! 	   (unless (eq (indirect-function mode) (indirect-function major-mode))
! 	     (funcall mode))))
  	((eq var 'eval)
  	 (save-excursion (eval val)))
  	(t (make-local-variable var)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2006-05-10 18:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-09  9:53 Mode loaded twice with Local Variables Michaël Cadilhac
2006-05-09 13:22 ` Chong Yidong
2006-05-09 13:53   ` Michaël Cadilhac
2006-05-09 16:08 ` Stuart D. Herring
2006-05-10 17:50   ` Richard Stallman
2006-05-10 18:20     ` Stuart D. Herring [this message]
2006-05-11 18:31       ` Richard Stallman
2006-05-10 18:29   ` Michaël Cadilhac
2006-05-10 19:59     ` Stuart D. Herring
2006-05-11 18:31       ` Richard Stallman
2006-05-11 19:00         ` Stuart D. Herring
2006-05-11 18:31     ` Richard Stallman
2006-06-14 23:09     ` Stuart D. Herring
2006-05-10  3:20 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56383.128.165.123.132.1147285233.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=emacs-devel@gnu.org \
    --cc=michael.cadilhac@lrde.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.