From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: rms@gnu.org
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Specifying mode in file variables trouble
Date: Tue, 23 Sep 2008 01:11:53 +0200 [thread overview]
Message-ID: <48D82639.2040602@gmail.com> (raw)
In-Reply-To: <48D79A25.7050000@gmail.com>
Lennart Borgman (gmail) wrote:
> Richard M. Stallman wrote:
>> Maybe, but I think most oftenly that will create name clashes.
>>
>> It will cause name clashes is you choose names of existing major modes,
>> but you can easily avoid using those.
>>
>> Here's what I suggest:
>>
>> If there is a customary name (say, `foo' for a kind of file which mixes
>> a few ordinary major modes, call the command `foo-mode'.
>>
>> Otherwise, if you want a command for the combination of two modes `a'
>> and `b', call it `a-b-mode'.
>>
>> Or we could use `a+b-mode' for such cases.
>
> I like the idea of using "+" here, that is a good mnemonic.
>
> For web template files (like PHP, JSP, Genshi etc) there are however
> often several major mode chunks involved. In for example a php file
> there may be chunks with these major modes
>
> - nxhtml-mode / html-mode
> - php-mode
> - css-mode
> - javascript-mode
>
> I currently use the name nxhtml-mumamo-mode (or html-mumamo-mode) for
> the multi major mode, which is of course not that very descriptive. The
> name begins with "nxhtml-" because that is the main major mode (there
> are only two levels allowed sofar, main major mode and sub chunks major
> modes).
>
> Along with your suggestion nxhtml+php-mode would be the most natural.
> This name does not tell the whole truth, but is perhaps still less
> cryptic than nxhtml-mumamo-mode. I am not quite sure.
>
>> (There are still good reasons to tell
>> that it is a multi major mode. The most difficult thing is support of
>> minor modes turn on/off and finding reasonable structures for that. Time
>> will tell I think.)
>>
>> Let's talk about this problem; maybe I can suggest a general solution
>> for it.
>
> There might be several problem, but the bug report I just recieved for
> Imenu illustrates one principal problem:
>
> https://bugs.launchpad.net/bugs/272526
>
> I have not looked into the details, but the problem reports says that
> Imenu does not work as expected when moving between chunks (with
> different major modes).
>
> The principal problem here is probably that Imenu should work across all
> chunks with the same major modes and preserve its chunk specifric values
> when moving between those chunks.
>
> So I am thinking about saving those values in a variable, something like
> this
>
> (make-variable-buffer-local 'mumamo-survive-minor-modes)
> (put 'mumamo-survive-minor-modes 'permanent-local t)
> (defvar mumamo-survive-minor-modes nil
> "Hold local minor mode variables specific major modes.
> Those values are saved when leaving a chunk with a certain
> major mode and restored when entering a chunk with the same
> major mode again.
>
> The value of this variable is an associative list where the key
> is a list with
>
> \(MAJOR-MODE MINOR-MODE)
>
> and the value is a stored value for the minor mode.")
>
> For storing the values I am thinking about using the code that does
> something similar for visual-line-mode where state variable values are
> stored in visual-line--saved-state.
>
> However the drawback is that this has to be implemented for every minor
> mode of this kind, but I can't see any way around it currently.
>
> ... eh, maybe another way to do it could be to save all buffer local
> variables this way and make exceptions for some ...
Here is something along the line of the last idea just above here:
(defun mumamo-save-buffer-locals (major)
"Save some local variables for major mode MAJOR.
This should be called before switching to a new chunks major
mode."
(let ((locals (buffer-local-variables)))
(setq locals (mapcar (lambda (local)
(unless (or
(memq (car local)
mumamo-buffer-locals-dont-set)
(memq (car local) mumamo-survive)
(get (car local) 'permanent-local)
)))
locals))
(setq locals (delq nil locals))
(setq mumamo-buffer-locals-per-major
(assq-delete-all major mumamo-buffer-locals-per-major))
(setq mumamo-buffer-locals-per-major
(cons (cons major-mode locals)
mumamo-buffer-locals-per-major))))
;; (benchmark 1000 '(mumamo-save-buffer-locals major-mode))
;; (benchmark 1000 '(mumamo-restore-buffer-locals major-mode))
(defun mumamo-restore-buffer-locals (major)
"Restore some local variables for major mode MAJOR.
This should be called after switching to a new chunks major
mode."
(let ((locals (cdr (assq major mumamo-buffer-locals-per-major)))
var
perm)
(dolist (rec locals)
(setq var (car rec))
(setq perm (get var 'permanent-local))
(unless (or perm
(memq var mumamo-buffer-locals-dont-set))
(setq var (cdr rec))))))
next prev parent reply other threads:[~2008-09-22 23:11 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-20 0:44 Specifying mode in file variables trouble Lennart Borgman (gmail)
2008-09-20 0:48 ` Lennart Borgman (gmail)
2008-09-20 0:59 ` Miles Bader
2008-09-20 1:06 ` Lennart Borgman (gmail)
2008-09-21 6:32 ` Richard M. Stallman
2008-09-21 12:33 ` Lennart Borgman (gmail)
2008-09-21 23:34 ` Richard M. Stallman
2008-09-22 0:38 ` Lennart Borgman (gmail)
2008-09-22 4:39 ` Richard M. Stallman
2008-09-22 13:14 ` Lennart Borgman (gmail)
2008-09-22 14:12 ` Stefan Monnier
2008-09-22 14:26 ` Lennart Borgman (gmail)
2008-09-23 4:40 ` Richard M. Stallman
2008-09-23 9:29 ` Lennart Borgman (gmail)
2008-09-23 19:47 ` Richard M. Stallman
2008-09-22 23:11 ` Lennart Borgman (gmail) [this message]
2008-09-23 4:40 ` Richard M. Stallman
2008-09-23 9:47 ` Lennart Borgman (gmail)
2008-09-23 19:47 ` Richard M. Stallman
2008-09-23 20:43 ` Lennart Borgman (gmail)
2008-09-24 13:47 ` Richard M. Stallman
2008-09-24 13:47 ` Richard M. Stallman
2008-09-24 17:21 ` Lennart Borgman (gmail)
2008-09-25 5:49 ` Richard M. Stallman
2008-09-25 6:28 ` tomas
2008-09-25 6:41 ` Paul R
2008-09-25 7:55 ` tomas
2008-09-25 8:35 ` Paul R
2008-09-25 16:42 ` Lennart Borgman
2008-09-27 4:39 ` Richard M. Stallman
2008-10-21 19:16 ` Lennart Borgman (gmail)
2008-10-22 5:21 ` tomas
2008-10-22 6:21 ` Richard M. Stallman
2008-09-23 19:47 ` Richard M. Stallman
2008-09-23 20:37 ` Lennart Borgman (gmail)
2008-09-24 13:47 ` Richard M. Stallman
2008-09-24 16:23 ` Lennart Borgman (gmail)
2008-09-25 5:50 ` Richard M. Stallman
2008-09-24 23:09 ` Lennart Borgman (gmail)
2008-09-23 4:40 ` Richard M. Stallman
2008-09-23 9:57 ` Lennart Borgman (gmail)
2008-09-23 16:03 ` Stefan Monnier
2008-09-23 17:22 ` Lennart Borgman (gmail)
2008-09-23 20:33 ` Stefan Monnier
2008-09-23 20:48 ` Lennart Borgman (gmail)
2008-09-23 21:27 ` Stefan Monnier
2008-09-23 21:30 ` Lennart Borgman (gmail)
2008-09-24 20:57 ` Richard M. Stallman
2008-09-24 21:29 ` Lennart Borgman (gmail)
2008-09-25 17:46 ` Richard M. Stallman
2008-09-25 21:34 ` Lennart Borgman (gmail)
2008-09-26 4:45 ` Richard M. Stallman
2008-09-26 4:45 ` Richard M. Stallman
2008-09-25 17:46 ` Selecting mumamo modes Richard M. Stallman
2008-09-25 21:12 ` Lennart Borgman (gmail)
2008-09-26 4:45 ` Richard M. Stallman
2008-10-21 19:20 ` Lennart Borgman (gmail)
2008-09-23 19:47 ` Specifying mode in file variables trouble Richard M. Stallman
2008-09-23 20:26 ` Lennart Borgman (gmail)
2008-09-24 20:56 ` Richard M. Stallman
2008-09-24 21:21 ` Lennart Borgman (gmail)
2008-09-25 17:46 ` Richard M. Stallman
2008-09-25 21:36 ` Lennart Borgman (gmail)
2008-09-26 4:45 ` Richard M. Stallman
2008-09-24 20:57 ` Richard M. Stallman
2008-09-24 21:45 ` Lennart Borgman (gmail)
2008-09-20 19:03 ` Stefan Monnier
2008-09-20 23:34 ` Lennart Borgman (gmail)
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=48D82639.2040602@gmail.com \
--to=lennart.borgman@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rms@gnu.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.