From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rsharman@pobox.com Newsgroups: gmane.emacs.devel Subject: Re: highlight-changes-mode Date: Wed, 6 Dec 2006 01:25:40 -0500 Message-ID: <17782.25188.121126.54191@cube.homenetwork> References: <17721.60660.980363.609046@kahikatea.snap.net.nz> <17725.23383.490888.442550@cube.homenetwork> <17770.17915.319182.723314@cube.homenetwork> <17770.35080.725821.391914@kahikatea.snap.net.nz> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1165433054 1523 80.91.229.10 (6 Dec 2006 19:24:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Dec 2006 19:24:14 +0000 (UTC) Cc: emacs-devel@gnu.org, rms@gnu.org, rsharman@pobox.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 06 20:24:11 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1Gs2NC-0000bi-DA for ged-emacs-devel@m.gmane.org; Wed, 06 Dec 2006 20:24:06 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gs2NB-00031J-Pi for ged-emacs-devel@m.gmane.org; Wed, 06 Dec 2006 14:24:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GrqFo-00026n-Kg for emacs-devel@gnu.org; Wed, 06 Dec 2006 01:27:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GrqFm-00026b-TP for emacs-devel@gnu.org; Wed, 06 Dec 2006 01:27:39 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrqFm-00026Y-NN for emacs-devel@gnu.org; Wed, 06 Dec 2006 01:27:38 -0500 Original-Received: from [209.217.78.152] (helo=mx1-1.spamtrap.magma.ca) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GrqFl-0007HV-8s; Wed, 06 Dec 2006 01:27:37 -0500 Original-Received: from mail1.magma.ca (mail1.internal.magma.ca [10.0.10.11]) by mx1-1.spamtrap.magma.ca (8.13.1/8.13.1) with ESMTP id kB66RS0e011884; Wed, 6 Dec 2006 01:27:28 -0500 Original-Received: from cube.homenetwork (ottawa-hs-209-217-110-164.d-ip.magma.ca [209.217.110.164]) by mail1.magma.ca (Magma's Mail Server) with ESMTP id kB66RROW010699; Wed, 6 Dec 2006 01:27:28 -0500 Original-Received: by cube.homenetwork (Postfix, from userid 1000) id 5641393CAA; Wed, 6 Dec 2006 01:25:40 -0500 (EST) Original-To: Nick Roberts In-Reply-To: <17770.35080.725821.391914@kahikatea.snap.net.nz> X-Mailer: VM 7.19 under Emacs 21.4.1 X-magma-MailScanner-Information: Magma Mailscanner Service X-magma-MailScanner: Clean X-Mailman-Approved-At: Wed, 06 Dec 2006 14:23:51 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:63372 Archived-At: 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