From: rsharman@pobox.com
Cc: emacs-devel@gnu.org, rms@gnu.org, rsharman@pobox.com
Subject: Re: highlight-changes-mode
Date: Wed, 6 Dec 2006 01:25:40 -0500 [thread overview]
Message-ID: <17782.25188.121126.54191@cube.homenetwork> (raw)
In-Reply-To: <17770.35080.725821.391914@kahikatea.snap.net.nz>
Nick Roberts writes:
>
> Also it might be a good idea to use
> define-minor-mode to define highlight-changes-mode.
>
Thanks, that's nice.
It looks as if I could simplify a lot by using define-global-minor-mode
for global-highlight-changes. However, to keep the existing functionality
where variable highlight-changes-global-changes-existing-buffers
allows existing buffers to be left alone and only new ones changed,
I need a minor change to define-global-minor-mode.
I added a new keyword :only-new EXPR which allows restricting
a change of mode to new only new buffers if EXPR is non-nil.
(So the default behaviour, without this keyword, is unchanged.)
With this I can remove nearly all the code for the global
highlight-changes.
Is this acceptable? Here's the change to easy-mmode.el that
implements what I need:
========================================================================
*** easy-mmode.el.orig Thu Aug 31 19:14:26 2006
--- easy-mmode.el Wed Dec 6 01:16:35 2006
***************
*** 278,290 ****
TURN-ON is a function that will be called with no args in every buffer
and that should try to turn MODE on if applicable for that buffer.
KEYS is a list of CL-style keyword arguments. As the minor mode
! defined by this function is always global, any :global keyword is
! ignored. Other keywords have the same meaning as in `define-minor-mode',
! which see. In particular, :group specifies the custom group.
! The most useful keywords are those that are passed on to the
! `defcustom'. It normally makes no sense to pass the :lighter
! or :keymap keywords to `define-global-minor-mode', since these
! are usually passed to the buffer-local version of the minor mode.
If MODE's set-up depends on the major mode in effect when it was
enabled, then disabling and reenabling MODE should make MODE work
--- 278,292 ----
TURN-ON is a function that will be called with no args in every buffer
and that should try to turn MODE on if applicable for that buffer.
KEYS is a list of CL-style keyword arguments. As the minor mode
! defined by this function is always global, any :global keyword
! is ignored. Keyword :only-new EXPR means don't change existing
! buffers if EXPR is non-nil. Other keywords have the same
! meaning as in `define-minor-mode', which see. In particular,
! :group specifies the custom group. The most useful keywords
! are those that are passed on to the `defcustom'. It normally
! makes no sense to pass the :lighter or :keymap keywords to
! `define-global-minor-mode', since these are usually passed to
! the buffer-local version of the minor mode.
If MODE's set-up depends on the major mode in effect when it was
enabled, then disabling and reenabling MODE should make MODE work
***************
*** 304,309 ****
--- 306,312 ----
(intern (concat global-mode-name "-check-buffers")))
(MODE-cmhh (intern (concat global-mode-name "-cmhh")))
(MODE-major-mode (intern (concat (symbol-name mode) "-major-mode")))
+ (only-new nil)
keyw)
;; Check keys.
***************
*** 312,317 ****
--- 315,321 ----
(case keyw
(:group (setq group (nconc group (list :group (pop keys)))))
(:global (setq keys (cdr keys)))
+ (:only-new (setq only-new (pop keys)))
(t (push keyw extra-keywords) (push (pop keys) extra-keywords))))
(unless group
***************
*** 344,352 ****
(remove-hook 'change-major-mode-hook ',MODE-cmhh))
;; Go through existing buffers.
! (dolist (buf (buffer-list))
! (with-current-buffer buf
! (if ,global-mode (,turn-on) (when ,mode (,mode -1))))))
;; Autoloading define-global-minor-mode autoloads everything
;; up-to-here.
--- 348,357 ----
(remove-hook 'change-major-mode-hook ',MODE-cmhh))
;; Go through existing buffers.
! (unless ,only-new
! (dolist (buf (buffer-list))
! (with-current-buffer buf
! (if ,global-mode (,turn-on) (when ,mode (,mode -1)))))))
;; Autoloading define-global-minor-mode autoloads everything
;; up-to-here.
========================================================================
Richard
next prev parent reply other threads:[~2006-12-06 6:25 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <17721.60660.980363.609046@kahikatea.snap.net.nz>
2006-10-23 5:11 ` highlight-changes-mode Richard Stallman
2006-10-23 18:39 ` highlight-changes-mode Richard Stallman
2006-10-24 0:16 ` highlight-changes-mode rsharman
2006-10-24 17:43 ` highlight-changes-mode Richard Stallman
2006-11-27 1:57 ` highlight-changes-mode rsharman
2006-11-27 6:43 ` highlight-changes-mode Nick Roberts
2006-11-28 2:15 ` highlight-changes-mode rsharman
2006-12-06 6:25 ` rsharman [this message]
2006-12-06 6:37 ` highlight-changes-mode rsharman
2006-12-06 18:44 ` highlight-changes-mode Richard Stallman
2006-12-06 19:58 ` highlight-changes-mode Drew Adams
2006-12-07 21:02 ` highlight-changes-mode Richard Stallman
2006-12-07 21:13 ` highlight-changes-mode Drew Adams
2006-12-09 18:55 ` global minor modes that can be overridden locally? [was: highlight-changes-mode] Drew Adams
2006-12-11 1:06 ` Richard Stallman
2006-12-11 1:16 ` Lennart Borgman
2006-12-11 1:45 ` Drew Adams
2006-12-11 1:52 ` Lennart Borgman
2006-12-11 1:58 ` Drew Adams
2006-12-12 2:57 ` Richard Stallman
2006-12-12 3:27 ` Lennart Borgman
2006-12-12 21:45 ` Richard Stallman
2006-12-12 23:02 ` Lennart Borgman
2006-12-12 4:06 ` Drew Adams
2006-12-12 4:25 ` global minor modes that can be overridden locally? Miles Bader
2006-12-12 5:00 ` Drew Adams
2006-12-29 16:25 ` Drew Adams
2006-12-29 22:15 ` Stefan Monnier
2006-12-29 22:40 ` Drew Adams
2006-12-30 6:24 ` Richard Stallman
2006-12-30 8:25 ` Drew Adams
2006-12-31 1:46 ` Richard Stallman
2006-12-30 22:43 ` Kim F. Storm
2006-12-30 23:27 ` Lennart Borgman (gmail)
2006-12-30 6:23 ` Richard Stallman
2006-12-12 11:08 ` Juanma Barranquero
2006-12-12 11:15 ` Miles Bader
2006-12-12 11:25 ` Juanma Barranquero
2006-12-12 11:33 ` Miles Bader
2006-12-12 11:59 ` Juanma Barranquero
2006-12-11 1:40 ` global minor modes that can be overridden locally? [was:highlight-changes-mode] Drew Adams
2006-12-12 2:58 ` Richard Stallman
2006-12-12 4:08 ` global minor modes that can be overridden locally?[was:highlight-changes-mode] Drew Adams
2006-12-12 21:45 ` Richard Stallman
2006-12-06 23:39 ` highlight-changes-mode rsharman
2006-12-07 21:03 ` highlight-changes-mode Richard Stallman
2006-12-09 19:40 ` highlight-changes-mode rsharman
2006-12-11 1:06 ` highlight-changes-mode Richard Stallman
2006-12-11 9:15 ` highlight-changes-mode Kim F. Storm
2006-12-12 2:58 ` highlight-changes-mode Richard Stallman
2006-12-12 3:16 ` highlight-changes-mode rsharman
2006-12-12 21:45 ` highlight-changes-mode Richard Stallman
2006-12-12 23:33 ` highlight-changes-mode rsharman
2006-12-14 5:29 ` highlight-changes-mode Richard Stallman
2006-11-27 15:38 ` highlight-changes-mode Richard Stallman
2006-11-28 2:04 ` highlight-changes-mode rsharman
2006-12-05 2:42 ` highlight-changes-mode rsharman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=17782.25188.121126.54191@cube.homenetwork \
--to=rsharman@pobox.com \
--cc=emacs-devel@gnu.org \
--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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).