From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 12 11:23:55 2010 Received: (at submit) by debbugs.gnu.org; 12 Apr 2010 15:23:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1LUR-0007hN-Jk for submit@debbugs.gnu.org; Mon, 12 Apr 2010 11:23:55 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1LUQ-0007hH-3L for submit@debbugs.gnu.org; Mon, 12 Apr 2010 11:23:54 -0400 Received: from lists.gnu.org ([199.232.76.165]:52988) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O1LUL-00065b-6R for submit@debbugs.gnu.org; Mon, 12 Apr 2010 11:23:49 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1LUK-0000dm-JP for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:23:48 -0400 Received: from [140.186.70.92] (port=44136 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1LUJ-0000dR-6G for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:23:48 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1LUF-0006qM-MW for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:23:46 -0400 Received: from ppsw-31.csi.cam.ac.uk ([131.111.8.131]:36133 helo=ppsw-1.csi.cam.ac.uk) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1LUF-0006qF-Hv for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:23:43 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from wlan-gw.st-edmunds.cam.ac.uk ([131.111.223.101]:52065 helo=Victoria.local) by ppsw-1.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.151]:587) with esmtpsa (PLAIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O1LUF-0001X7-3a (Exim 4.70) for bug-gnu-emacs@gnu.org (return-path ); Mon, 12 Apr 2010 16:23:43 +0100 From: Leo To: bug-gnu-emacs@gnu.org Subject: 23.1.95; why saving empty abbrev tables Date: Mon, 12 Apr 2010 16:23:44 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Why empty abbrev tables are saved to file? It seems to make it more difficult for editing (edit-abbrevs) because the buffer is full of empty abbrev. I wonder if saving only non-empty tables is better and user friendlier. For example, any harm of doing something like this: (defun abbrev-table-empty-p (table) "Return nil if there are no abbrev symbols in abbrev table object TABLE." (unless (abbrev-table-p table) (error "Non abbrev table object")) (not (catch 'some (mapatoms (lambda (sym) (when (abbrev-symbol (symbol-name sym) table) (throw 'some t))) table)))) (defadvice write-abbrev-file (around nonempty-abbrev-tables activate) "Ignore empty abbrev tables when writing to FILE." (let ((file (ad-get-arg 0)) (coding-system-for-write 'emacs-mule) (tables (loop for table in abbrev-table-name-list unless (abbrev-table-empty-p (symbol-value table)) collect table))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) (with-temp-file file (insert ";;-*-coding: emacs-mule;-*-\n") (dolist (table (sort tables (lambda (s1 s2) (string< (symbol-name s1) (symbol-name s2))))) (insert-abbrev-table-description table nil))))) From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 12 14:32:14 2010 Received: (at 5937) by debbugs.gnu.org; 12 Apr 2010 18:32:14 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OQg-00016G-AN for submit@debbugs.gnu.org; Mon, 12 Apr 2010 14:32:14 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OQe-000168-Q9 for 5937@debbugs.gnu.org; Mon, 12 Apr 2010 14:32:13 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAMMDw0tMCqWu/2dsb2JhbACbOnK8eoUMBItG X-IronPort-AV: E=Sophos;i="4.52,192,1270440000"; d="scan'208";a="60694386" Received: from 76-10-165-174.dsl.teksavvy.com (HELO pastel.home) ([76.10.165.174]) by ironport2-out.pppoe.ca with ESMTP; 12 Apr 2010 14:32:08 -0400 Received: by pastel.home (Postfix, from userid 20848) id 7BD117F1B; Mon, 12 Apr 2010 14:32:07 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Mon, 12 Apr 2010 14:32:07 -0400 In-Reply-To: (Leo's message of "Mon, 12 Apr 2010 16:23:44 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > Why empty abbrev tables are saved to file? Don't know. > It seems to make it more difficult for editing (edit-abbrevs) because > the buffer is full of empty abbrev. I wonder if saving only non-empty > tables is better and user friendlier. It does sound like a good idea. Any objection? > (defun abbrev-table-empty-p (table) > "Return nil if there are no abbrev symbols in abbrev table object TABLE." > (unless (abbrev-table-p table) > (error "Non abbrev table object")) > (not (catch 'some > (mapatoms (lambda (sym) > (when (abbrev-symbol (symbol-name sym) table) > (throw 'some t))) > table)))) > (defadvice write-abbrev-file (around nonempty-abbrev-tables activate) > "Ignore empty abbrev tables when writing to FILE." > (let ((file (ad-get-arg 0)) > (coding-system-for-write 'emacs-mule) > (tables (loop for table in abbrev-table-name-list > unless (abbrev-table-empty-p (symbol-value table)) > collect table))) > (or (and file (> (length file) 0)) (setq file abbrev-file-name)) > (with-temp-file file > (insert ";;-*-coding: emacs-mule;-*-\n") > (dolist (table (sort tables > (lambda (s1 s2) > (string< (symbol-name s1) > (symbol-name s2))))) > (insert-abbrev-table-description table nil))))) Obviously, defadvice wouldn't be the right approach for us. And rather than (abbrev-symbol (symbol-name sym) table), we can use (symbol-value sym). We should also eliminate abbrev tables that only contain "system abbrevs". Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 15 06:27:05 2010 Received: (at 5937) by debbugs.gnu.org; 15 Apr 2010 10:27:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2MHp-0001gy-FX for submit@debbugs.gnu.org; Thu, 15 Apr 2010 06:27:05 -0400 Received: from ppsw-33.csi.cam.ac.uk ([131.111.8.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2MHm-0001gc-8x for 5937@debbugs.gnu.org; Thu, 15 Apr 2010 06:27:03 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]:36988) by ppsw-33.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:587) with esmtpsa (LOGIN:sl392) (TLSv1:DHE-RSA-AES128-SHA:128) id 1O2MHf-0004nN-Cl (Exim 4.70) (return-path ); Thu, 15 Apr 2010 11:26:55 +0100 From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Thu, 15 Apr 2010 11:26:55 +0100 In-Reply-To: (Stefan Monnier's message of "Mon, 12 Apr 2010 14:32:07 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) On 2010-04-12 19:32 +0100, Stefan Monnier wrote: >> Why empty abbrev tables are saved to file? > > Don't know. > >> It seems to make it more difficult for editing (edit-abbrevs) because >> the buffer is full of empty abbrev. I wonder if saving only non-empty >> tables is better and user friendlier. > > It does sound like a good idea. Any objection? I have been using this in my init file and I like it. It makes it easier to see what's actually defined. (defun abbrev-table-empty-p (table) "Return nil if there are no abbrev symbols in abbrev table object TABLE." (unless (abbrev-table-p table) (error "Non abbrev table object")) (not (catch 'some (mapatoms (lambda (sym) (when (abbrev-symbol (symbol-name sym) table) (throw 'some t))) table)))) (defadvice prepare-abbrev-list-buffer (around nonempty-abbrev-tables activate) "Ignore empty abbrev tables." (let ((abbrev-table-name-list (loop for table in abbrev-table-name-list unless (abbrev-table-empty-p (symbol-value table)) collect table))) ad-do-it)) (defadvice write-abbrev-file (around nonempty-abbrev-tables activate) "Ignore empty abbrev tables when writing to FILE." (let ((abbrev-table-name-list (loop for table in abbrev-table-name-list unless (abbrev-table-empty-p (symbol-value table)) collect table))) ad-do-it)) [...] > Obviously, defadvice wouldn't be the right approach for us. > And rather than (abbrev-symbol (symbol-name sym) table), we can use > (symbol-value sym). > We should also eliminate abbrev tables that only contain "system > abbrevs". Regarding the :system property, I have experienced some oddity but I by-passed that instead of looking into it for lack of time. Here's what happened. When I use define-abbrev to define some system abbrevs and then M-x edit-abbrevs and move to the table where those abbrevs are defined then paste some non-system abbrevs from, for example, another abbrev file. Those pasted abbrevs are treated as system abbrevs and not saved. Sometimes when the table already have non-system abbrevs, they are turned into system ones and get lost. I had a backup of the abbrev file so that didn't cause me any trouble. > > Stefan Leo From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 15 08:44:54 2010 Received: (at 5937) by debbugs.gnu.org; 15 Apr 2010 12:44:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2ORC-0003Av-4L for submit@debbugs.gnu.org; Thu, 15 Apr 2010 08:44:54 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2OR9-0003Ap-K0 for 5937@debbugs.gnu.org; Thu, 15 Apr 2010 08:44:52 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAIGmxktMCpxH/2dsb2JhbACbbXK+GoUOBIta X-IronPort-AV: E=Sophos;i="4.52,212,1270440000"; d="scan'208";a="60924247" Received: from 76-10-156-71.dsl.teksavvy.com (HELO pastel.home) ([76.10.156.71]) by ironport2-out.pppoe.ca with ESMTP; 15 Apr 2010 08:44:46 -0400 Received: by pastel.home (Postfix, from userid 20848) id 6E86F7F1B; Thu, 15 Apr 2010 08:44:45 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Thu, 15 Apr 2010 08:44:45 -0400 In-Reply-To: (Leo's message of "Thu, 15 Apr 2010 11:26:55 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.4 (--) > When I use define-abbrev to define some system abbrevs and then M-x > edit-abbrevs and move to the table where those abbrevs are defined then > paste some non-system abbrevs from, for example, another abbrev file. > Those pasted abbrevs are treated as system abbrevs and not saved. > Sometimes when the table already have non-system abbrevs, they are > turned into system ones and get lost. Please make a separate bug report about it (and try to give a more precise recipe for it). Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 15 14:29:17 2010 Received: (at control) by debbugs.gnu.org; 15 Apr 2010 18:29:17 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2ToS-0006Lv-G1 for submit@debbugs.gnu.org; Thu, 15 Apr 2010 14:29:16 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2ToQ-0006Lk-Gy for control@debbugs.gnu.org; Thu, 15 Apr 2010 14:29:15 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1O2ToE-0004Yp-8p; Thu, 15 Apr 2010 14:29:02 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19399.23277.131729.705471@fencepost.gnu.org> Date: Thu, 15 Apr 2010 14:29:01 -0400 From: Glenn Morris To: control Subject: control X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: black X-Ran: I2osu0uqhYF(oLTuF1AB"l21"KvQ3eLee*z=|sh+n2)N_$p!_]VW&cPXC&Mgg;U0FphPs\ X-Debbugs-No-Ack: yes X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) reassign 5922 aquamacs severity 5931 minor tags 5931 moreinfo merge 5252 5921 retitle 5921 /sw and /opt/local on OSX tags 5531 moreinfo tags 5568 wontfix notabug severity 5568 minor reassign 5932 emacs,cc-mode reassign 5953 emacs,cc-mode severity 5952 wishlist severity 5953 wishlist tags 5952 patch reassign 5946 emacs,ns severity 5937 minor From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 16 06:36:46 2010 Received: (at submit) by debbugs.gnu.org; 16 Apr 2010 10:36:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2iuj-0005yB-Nq for submit@debbugs.gnu.org; Fri, 16 Apr 2010 06:36:46 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2iuh-0005y6-0q for submit@debbugs.gnu.org; Fri, 16 Apr 2010 06:36:44 -0400 Received: from lists.gnu.org ([199.232.76.165]:51469) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O2iub-0003Vy-Kb for submit@debbugs.gnu.org; Fri, 16 Apr 2010 06:36:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2iua-0005tQ-PT for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:36:37 -0400 Received: from [140.186.70.92] (port=54653 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2iuY-0005sU-3e for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:36:35 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL,T_TVD_MIME_NO_HEADERS autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2iuW-0007xM-6T for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:36:33 -0400 Received: from lo.gmane.org ([80.91.229.12]:55745) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2iuV-0007wr-Sr for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:36:32 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O2iuT-0007e0-AH for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 12:36:29 +0200 Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Apr 2010 12:36:29 +0200 Received: from sdl.web by smaug.linux.pwf.cam.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Apr 2010 12:36:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org connect(): No such file or directory From: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Date: Fri, 16 Apr 2010 11:36:21 +0100 Organization: University of Cambridge Lines: 108 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: smaug.linux.pwf.cam.ac.uk User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:O3uunOdg5dv6GDDhNWNu46YSKBY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) --=-=-= On 2010-04-12 19:32 +0100, Stefan Monnier wrote: >> It seems to make it more difficult for editing (edit-abbrevs) because >> the buffer is full of empty abbrev. I wonder if saving only non-empty >> tables is better and user friendlier. > > It does sound like a good idea. Any objection? Would the following patch be acceptable? * lisp/abbrev.el (write-abbrev-file prepare-abbrev-list-buffer): ignore empty abbrev tables (abbrev-table-empty-p): new function. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=abbrev.diff Content-Description: abbrev.diff diff --git a/lisp/abbrev.el b/lisp/abbrev.el index b72bdbb..21411a5 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -127,15 +127,20 @@ Otherwise display all abbrevs." (defun prepare-abbrev-list-buffer (&optional local) (with-current-buffer (get-buffer-create "*Abbrevs*") (erase-buffer) - (if local - (insert-abbrev-table-description - (abbrev-table-name local-abbrev-table) t) - (dolist (table abbrev-table-name-list) - (insert-abbrev-table-description table t))) - (goto-char (point-min)) - (set-buffer-modified-p nil) - (edit-abbrevs-mode) - (current-buffer))) + (let ((abbrev-table-name-list + (delete nil (mapcar (lambda (tn) + (unless (abbrev-table-empty-p (symbol-value tn)) + tn)) + abbrev-table-name-list)))) + (if local + (insert-abbrev-table-description + (abbrev-table-name local-abbrev-table) t) + (dolist (table abbrev-table-name-list) + (insert-abbrev-table-description table t))) + (goto-char (point-min)) + (set-buffer-modified-p nil) + (edit-abbrevs-mode) + (current-buffer)))) (defun edit-abbrevs-mode () "Major mode for editing the list of abbrev definitions. @@ -232,7 +237,12 @@ specified in `abbrev-file-name' is used." abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) - (let ((coding-system-for-write 'emacs-mule)) + (let ((coding-system-for-write 'emacs-mule) + (tables (delete nil (mapcar + (lambda (tn) + (unless (abbrev-table-empty-p (symbol-value tn)) + tn)) + abbrev-table-name-list)))) (with-temp-file file (insert ";;-*-coding: emacs-mule;-*-\n") (dolist (table @@ -242,10 +252,9 @@ specified in `abbrev-file-name' is used." ;; user keeps their home directory in a revision ;; control system, and is therefore keeping multiple ;; slightly-differing copies loosely synchronized. - (sort (copy-sequence abbrev-table-name-list) - (lambda (s1 s2) - (string< (symbol-name s1) - (symbol-name s2))))) + (sort tables (lambda (s1 s2) + (string< (symbol-name s1) + (symbol-name s2))))) (insert-abbrev-table-description table nil))))) (defun add-mode-abbrev (arg) @@ -419,6 +428,16 @@ PROPS is a list of properties." (and (vectorp object) (numberp (abbrev-table-get object :abbrev-table-modiff)))) +(defun abbrev-table-empty-p (object) + "Return nil if there are no abbrev symbols in OBJECT." + (unless (abbrev-table-p object) + (error "Non abbrev table object")) + (not (catch 'some + (mapatoms (lambda (sym) + (when (symbol-value sym) + (throw 'some t))) + object)))) + (defvar global-abbrev-table (make-abbrev-table) "The abbrev table whose abbrevs affect all buffers. Each buffer may also have a local abbrev table. --=-=-= Thanks, Leo --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 26 23:49:18 2010 Received: (at submit) by debbugs.gnu.org; 27 Apr 2010 03:49:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6bnS-0006hT-Fc for submit@debbugs.gnu.org; Mon, 26 Apr 2010 23:49:18 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6bnP-0006hO-Uw for submit@debbugs.gnu.org; Mon, 26 Apr 2010 23:49:16 -0400 Received: from lists.gnu.org ([199.232.76.165]:40008) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O6bnM-000072-HF for submit@debbugs.gnu.org; Mon, 26 Apr 2010 23:49:12 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6bnM-0005Sm-5k for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2010 23:49:12 -0400 Received: from [140.186.70.92] (port=50394 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6bnK-0005ST-QO for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2010 23:49:11 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6bnJ-00070r-J4 for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2010 23:49:10 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:20047 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6bnJ-00070e-H0 for bug-gnu-emacs@gnu.org; Mon, 26 Apr 2010 23:49:09 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAIr71UvO+KoL/2dsb2JhbACcSHK+boUMBIwO X-IronPort-AV: E=Sophos;i="4.52,277,1270440000"; d="scan'208";a="62656438" Received: from 206-248-170-11.dsl.teksavvy.com (HELO ceviche.home) ([206.248.170.11]) by ironport2-out.pppoe.ca with ESMTP; 26 Apr 2010 23:49:07 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 81B50660DC; Mon, 26 Apr 2010 23:49:07 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Mon, 26 Apr 2010 23:49:07 -0400 In-Reply-To: (Leo's message of "Fri, 16 Apr 2010 11:36:21 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) >>> It seems to make it more difficult for editing (edit-abbrevs) because >>> the buffer is full of empty abbrev. I wonder if saving only non-empty >>> tables is better and user friendlier. >> It does sound like a good idea. Any objection? > Would the following patch be acceptable? Actually, having tried it now for a while I do have an objection: it makes it harder to add entries to an abbrev-table if that table is empty. So I think a better option is to sort the tables such that empty tables are pushed to the end. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 27 04:47:01 2010 Received: (at submit) by debbugs.gnu.org; 27 Apr 2010 08:47:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6gRY-0000Td-Mx for submit@debbugs.gnu.org; Tue, 27 Apr 2010 04:47:01 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6gRW-0000TT-M6 for submit@debbugs.gnu.org; Tue, 27 Apr 2010 04:46:59 -0400 Received: from lists.gnu.org ([199.232.76.165]:46414) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O6gRT-0007Nv-Vi for submit@debbugs.gnu.org; Tue, 27 Apr 2010 04:46:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6gRT-0000P5-9B for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 04:46:55 -0400 Received: from [140.186.70.92] (port=40735 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6gRA-0000NM-Og for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 04:46:54 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6gR5-000544-EQ for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 04:46:36 -0400 Received: from lo.gmane.org ([80.91.229.12]:42763) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6gR5-00053v-4i for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 04:46:31 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O6gR3-0002i9-LH for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 10:46:29 +0200 Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Apr 2010 10:46:29 +0200 Received: from sdl.web by smaug.linux.pwf.cam.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Apr 2010 10:46:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org connect(): No such file or directory From: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Date: Tue, 27 Apr 2010 09:46:17 +0100 Organization: University of Cambridge Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: smaug.linux.pwf.cam.ac.uk User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:gSiej281VpO6SYgF8NPIYJowSXU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) On 2010-04-27 04:49 +0100, Stefan Monnier wrote: >>>> It seems to make it more difficult for editing (edit-abbrevs) because >>>> the buffer is full of empty abbrev. I wonder if saving only non-empty >>>> tables is better and user friendlier. >>> It does sound like a good idea. Any objection? >> Would the following patch be acceptable? > > Actually, having tried it now for a while I do have an objection: it > makes it harder to add entries to an abbrev-table if that table > is empty. > > So I think a better option is to sort the tables such that empty tables > are pushed to the end. I thought of this question when creating the patch. I wasn't sure how best to offer the option to add abbrevs to empty tables. When I first tried out abbrev I was confused at edit-abbrevs by all those empty tables. For example, the editing abbrevs buffer could easily have 1000 lines with the empty tables show up. I thought I had done something wrong with those C-x ail stuff. In the end I didn't use abbrev for 2-3 years until last year when I started using snippet. I think users use edit-abbrevs often to view and edit existing abbrevs or adding new ones to a non-empty table. When an abbrev tale is empty it is most likely the user hasn't used abbrevs in the major mode associated with it. Personally, I prefer keeping the edit abbrevs buffer smaller. It is cleaner and less confusing. Do you think we can address this issue in another way for example by offering a key biding to enter an empty table? For example, make M-RET move point to the end of current abbrev table and asking for a table name (with completion)? (this is similar to M-RET in org mode) > Stefan Leo From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 27 06:13:14 2010 Received: (at submit) by debbugs.gnu.org; 27 Apr 2010 10:13:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6hn0-0001H5-F4 for submit@debbugs.gnu.org; Tue, 27 Apr 2010 06:13:14 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6hmy-0001Gz-4M for submit@debbugs.gnu.org; Tue, 27 Apr 2010 06:13:13 -0400 Received: from lists.gnu.org ([199.232.76.165]:55833) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O6hmv-00017P-Gd for submit@debbugs.gnu.org; Tue, 27 Apr 2010 06:13:09 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6hmu-0005LV-MA for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:13:08 -0400 Received: from [140.186.70.92] (port=46742 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6hmo-0005H2-Ag for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:13:08 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6hmm-00039J-CM for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:13:01 -0400 Received: from lo.gmane.org ([80.91.229.12]:44493) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6hmm-000396-13 for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:13:00 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O6hmj-0004V8-QM for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 12:12:57 +0200 Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Apr 2010 12:12:57 +0200 Received: from sdl.web by smaug.linux.pwf.cam.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Apr 2010 12:12:57 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org connect(): No such file or directory From: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Date: Tue, 27 Apr 2010 11:12:49 +0100 Organization: University of Cambridge Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: smaug.linux.pwf.cam.ac.uk User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:f+53V9UL5NOnx92/VALFKb5uNHU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) On 2010-04-27 09:46 +0100, Leo wrote: > Do you think we can address this issue in another way for example by > offering a key biding to enter an empty table? For example, make M-RET > move point to the end of current abbrev table and asking for a table > name (with completion)? (this is similar to M-RET in org mode) The attached patch does this. Could you try and see if you like it? diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 21411a5..c27f29a 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -73,8 +73,9 @@ to enable or disable Abbrev mode in the current buffer." (defvar edit-abbrevs-map (let ((map (make-sparse-keymap))) - (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) - (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) + (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) + (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) + (define-key map [(meta return)] 'edit-abbrevs-new-table-entry) map) "Keymap used in `edit-abbrevs'.") @@ -175,6 +176,24 @@ or may be omitted (it is usually omitted)." (define-abbrevs t) (set-buffer-modified-p nil))) +(defun edit-abbrevs-new-table-entry (tablename) + "Enter a new table entry for TABLENAME into current buffer." + (interactive + (list (intern-soft + (completing-read "Table name: " + (mapcar 'symbol-name abbrev-table-name-list) + (lambda (tn) + (abbrev-table-empty-p + (symbol-value (intern-soft tn)))) + t)))) + (or (looking-at "^(.*)$") + (and (re-search-forward "^(.*)$" nil t) + (goto-char (match-beginning 0))) + (goto-char (point-max))) + (unless (bolp) (insert "\n")) + (insert-abbrev-table-description tablename t) + (forward-line -2)) + (defun define-abbrevs (&optional arg) "Define abbrevs according to current visible buffer contents. See documentation of `edit-abbrevs' for info on the format of the From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 27 06:33:02 2010 Received: (at submit) by debbugs.gnu.org; 27 Apr 2010 10:33:02 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6i6A-0002Ob-DQ for submit@debbugs.gnu.org; Tue, 27 Apr 2010 06:33:02 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6i67-0002NJ-36 for submit@debbugs.gnu.org; Tue, 27 Apr 2010 06:33:00 -0400 Received: from lists.gnu.org ([199.232.76.165]:49952) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1O6i61-0001Yj-Dn for submit@debbugs.gnu.org; Tue, 27 Apr 2010 06:32:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6i60-0001vl-Qv for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:32:52 -0400 Received: from [140.186.70.92] (port=51246 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6i5u-0001uo-NN for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:32:52 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6i5t-0005xE-AZ for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:32:46 -0400 Received: from lo.gmane.org ([80.91.229.12]:40065) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6i5t-0005x1-3Z for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 06:32:45 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O6i5q-0003WK-L7 for bug-gnu-emacs@gnu.org; Tue, 27 Apr 2010 12:32:42 +0200 Received: from smaug.linux.pwf.cam.ac.uk ([193.60.95.72]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Apr 2010 12:32:42 +0200 Received: from sdl.web by smaug.linux.pwf.cam.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 27 Apr 2010 12:32:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org connect(): No such file or directory From: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Date: Tue, 27 Apr 2010 11:32:33 +0100 Organization: University of Cambridge Lines: 20 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: smaug.linux.pwf.cam.ac.uk User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:5QIh1wWheDHWatfjiLpOs7EFB0s= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) On 2010-04-27 09:46 +0100, Leo wrote: > When I first tried out abbrev I was confused at edit-abbrevs by all > those empty tables. For example, the editing abbrevs buffer could easily > have 1000 lines with the empty tables show up. I thought I had done > something wrong with those C-x ail stuff. In the end I didn't use abbrev > for 2-3 years until last year when I started using snippet. While recollecting some of the surprises, I think there's another one. The meaning of C-x C-s is different in edit-abbrevs. C-x C-s usually means things have been saved and are safe unless something happen to the harddisk. In abbrevs it is not. And sometimes one doesn't get the chance to actually save it because emacs crashes halfway. I would propose separating C-x C-s and C-c C-c. C-x C-s should stay close to the global key binding. Leo From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 27 01:10:06 2011 Received: (at 5937) by debbugs.gnu.org; 27 Mar 2011 05:10:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3iEn-0007tW-JE for submit@debbugs.gnu.org; Sun, 27 Mar 2011 01:10:06 -0400 Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3iEk-0007sx-G0 for 5937@debbugs.gnu.org; Sun, 27 Mar 2011 01:10:03 -0400 Received: by iwn39 with SMTP id 39so1889835iwn.3 for <5937@debbugs.gnu.org>; Sat, 26 Mar 2011 22:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=JtY59skK0TzErIvGAGOBzMr0+x+X/TX3qHfPmzeAxHY=; b=TinUYfE0sEITqNoprsrAHL0mWNoRaR54Wmmfo8ucxzc5rDKdBnkEtvauuRPL2RegHB DiJhhmocG7giyM+S6PGppJFPckryKzMbrVsQdd+ygEvt4b0KmUNbbt1o+Cq380z5UtqQ /yPwNWlo9JqFPAvkD1EMPbONmHiMqtZomOnDw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=m2COue1XRxcZGXWeXCvt0TZFWAsH5dB7jsqTEMj/Hb6OxO7xwqTyYYiKrglg8WYSJU jN/FBmZ/vaiwOIBQA7PxzaI4Zd+lI5ozHFdvuC/CQQw48Co/fivUK4vake9X0kMPWPxo wYti8RmHHWoghc/fFxzWffCq0A28usIO6z+oM= Received: by 10.43.55.141 with SMTP id vy13mr2341379icb.188.1301202596742; Sat, 26 Mar 2011 22:09:56 -0700 (PDT) Received: from Victoria.local ([114.249.26.81]) by mx.google.com with ESMTPS id 19sm1927491ibx.52.2011.03.26.22.09.49 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 Mar 2011 22:09:55 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Sun, 27 Mar 2011 13:09:42 +0800 In-Reply-To: (Stefan Monnier's message of "Mon, 26 Apr 2010 23:49:07 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) --=-=-= On 2010-04-27 11:49 +0800, Stefan Monnier wrote: > Actually, having tried it now for a while I do have an objection: it > makes it harder to add entries to an abbrev-table if that table > is empty. > > So I think a better option is to sort the tables such that empty tables > are pushed to the end. > > > Stefan Hello Stefan, I propose we allow C-u M-x edit-abbrevs to include all abbrev tables but default to include only nonempty tables. Here is an updated patch. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment Content-Description: abbrev patch === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-03-22 15:38:40 +0000 +++ lisp/abbrev.el 2011-03-27 04:56:22 +0000 @@ -104,7 +104,7 @@ prefix arg, display only local, i.e. mode-specific, abbrevs. Otherwise display all abbrevs." (interactive "P") - (display-buffer (prepare-abbrev-list-buffer local))) + (display-buffer (prepare-abbrev-list-buffer (and local 'local)))) (defun abbrev-table-name (table) "Value is the name of abbrev table TABLE." @@ -116,14 +116,28 @@ (setq tables (cdr tables))) found)) -(defun prepare-abbrev-list-buffer (&optional local) - (let ((local-table local-abbrev-table)) +(defun abbrev-nonempty-table-names (&optional ignore-system) + "Return a list of nonempty abbrev table names. +If IGNORE-SYSTEM is non-nil, system definitions are ignored." + (delete nil + (mapcar (lambda (tn) + (unless (abbrev-table-empty-p + (symbol-value tn) ignore-system) + tn)) + abbrev-table-name-list))) + +;; HOW takes value: nil, local or all. +(defun prepare-abbrev-list-buffer (&optional how) + (let ((local-table local-abbrev-table) + (tables (if (eq how 'all) + abbrev-table-name-list + (abbrev-nonempty-table-names)))) (with-current-buffer (get-buffer-create "*Abbrevs*") (erase-buffer) - (if local + (if (eq how 'local) (insert-abbrev-table-description (abbrev-table-name local-table) t) - (dolist (table abbrev-table-name-list) + (dolist (table tables) (insert-abbrev-table-description table t))) (goto-char (point-min)) (set-buffer-modified-p nil) @@ -140,10 +154,11 @@ (use-local-map edit-abbrevs-map) (run-mode-hooks 'edit-abbrevs-mode-hook)) -(defun edit-abbrevs () +(defun edit-abbrevs (&optional all) "Alter abbrev definitions by editing a list of them. Selects a buffer containing a list of abbrev definitions. -You can edit them and type \\\\[edit-abbrevs-redefine] to redefine abbrevs +Use \\[universal-argument] to include empty abbrev tables. You can edit +them and type \\\\[edit-abbrevs-redefine] to redefine abbrevs according to your editing. Buffer contains a header line for each abbrev table, which is the abbrev table name in parentheses. @@ -152,8 +167,8 @@ where NAME and EXPANSION are strings with quotes, USECOUNT is an integer, and HOOK is any valid function or may be omitted (it is usually omitted)." - (interactive) - (switch-to-buffer (prepare-abbrev-list-buffer))) + (interactive "P") + (switch-to-buffer (prepare-abbrev-list-buffer (and all 'all)))) (defun edit-abbrevs-redefine () "Redefine abbrevs according to current buffer contents." @@ -225,7 +240,8 @@ abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) - (let ((coding-system-for-write 'utf-8)) + (let ((coding-system-for-write 'utf-8) + (tables (abbrev-nonempty-table-names t))) (with-temp-buffer (dolist (table ;; We sort the table in order to ease the automatic @@ -234,10 +250,9 @@ ;; user keeps their home directory in a revision ;; control system, and is therefore keeping multiple ;; slightly-differing copies loosely synchronized. - (sort (copy-sequence abbrev-table-name-list) - (lambda (s1 s2) - (string< (symbol-name s1) - (symbol-name s2))))) + (sort tables (lambda (s1 s2) + (string< (symbol-name s1) + (symbol-name s2))))) (insert-abbrev-table-description table nil)) (when (unencodable-char-position (point-min) (point-max) 'utf-8) (setq coding-system-for-write @@ -420,6 +435,18 @@ (and (vectorp object) (numberp (abbrev-table-get object :abbrev-table-modiff)))) +(defun abbrev-table-empty-p (object &optional ignore-system) + "Return nil if there are no abbrev symbols in OBJECT. +If IGNORE-SYSTEM is non-nil, system definitions are ignored." + (unless (abbrev-table-p object) + (error "Non abbrev table object")) + (not (catch 'some + (mapatoms (lambda (abbrev) + (unless (or (zerop (length (symbol-name abbrev))) + (and ignore-system (abbrev-get abbrev :system))) + (throw 'some t))) + object)))) + (defvar global-abbrev-table (make-abbrev-table) "The abbrev table whose abbrevs affect all buffers. Each buffer may also have a local abbrev table. --=-=-= Leo --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 27 13:28:13 2011 Received: (at submit) by debbugs.gnu.org; 27 Mar 2011 17:28:13 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3tl7-0000Sw-B6 for submit@debbugs.gnu.org; Sun, 27 Mar 2011 13:28:13 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3tl4-0000Sk-AA for submit@debbugs.gnu.org; Sun, 27 Mar 2011 13:28:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3tkx-0002VY-Lg for submit@debbugs.gnu.org; Sun, 27 Mar 2011 13:28:04 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:34201) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3tkx-0002VU-Ii for submit@debbugs.gnu.org; Sun, 27 Mar 2011 13:28:03 -0400 Received: from [140.186.70.92] (port=39168 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q3tkw-0001pz-9I for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 13:28:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3tku-0002VC-BT for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 13:28:01 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:58041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3tku-0002UN-0d for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 13:28:00 -0400 Received: from [192.168.178.29] (brln-4dbc6fd4.pool.mediaWays.net [77.188.111.212]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0LnYoV-1PV6Ys0mr9-00hw28; Sun, 27 Mar 2011 19:27:57 +0200 Message-ID: <4D8F752C.2000605@easy-emacs.de> Date: Sun, 27 Mar 2011 19:34:36 +0200 From: =?ISO-8859-15?Q?Andreas_R=F6hler?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:85wLPba0eX3iq4mdPYvZ15tpTcHCiIxVSsC+Si2k/YL Xsf0ltv0cf5wEdGWBSQLdkpQ8CLB0dk4eAC8pC2qemmiEZf7CZ fOAkPSeVoeYlzeEu6/Vzz314uAgeaMujyb0G3JIlJGRcezF2QO ioNpmHTxkeylGvkuaTKvNk+YlLjicmv/x6//AfJJycudSykRV1 PhnFhbBNnFDKPSJvVWivPYFg/1g+CoXiaEbvdUTmeg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) Am 27.03.2011 07:09, schrieb Leo: > On 2010-04-27 11:49 +0800, Stefan Monnier wrote: >> Actually, having tried it now for a while I do have an objection: it >> makes it harder to add entries to an abbrev-table if that table >> is empty. >> >> So I think a better option is to sort the tables such that empty tables >> are pushed to the end. >> >> >> Stefan > > Hello Stefan, > > I propose we allow C-u M-x edit-abbrevs to include all abbrev tables but > default to include only nonempty tables. > > Here is an updated patch. > > > > > === modified file 'lisp/abbrev.el' > --- lisp/abbrev.el 2011-03-22 15:38:40 +0000 > +++ lisp/abbrev.el 2011-03-27 04:56:22 +0000 > @@ -104,7 +104,7 @@ > prefix arg, display only local, i.e. mode-specific, abbrevs. > Otherwise display all abbrevs." > (interactive "P") > - (display-buffer (prepare-abbrev-list-buffer local))) > + (display-buffer (prepare-abbrev-list-buffer (and local 'local)))) > > (defun abbrev-table-name (table) > "Value is the name of abbrev table TABLE." > @@ -116,14 +116,28 @@ > (setq tables (cdr tables))) > found)) > > -(defun prepare-abbrev-list-buffer (&optional local) > - (let ((local-table local-abbrev-table)) > +(defun abbrev-nonempty-table-names (&optional ignore-system) > + "Return a list of nonempty abbrev table names. > +If IGNORE-SYSTEM is non-nil, system definitions are ignored." > + (delete nil > + (mapcar (lambda (tn) > + (unless (abbrev-table-empty-p > + (symbol-value tn) ignore-system) > + tn)) > + abbrev-table-name-list))) > + > +;; HOW takes value: nil, local or all. > +(defun prepare-abbrev-list-buffer (&optional how) > + (let ((local-table local-abbrev-table) > + (tables (if (eq how 'all) > + abbrev-table-name-list > + (abbrev-nonempty-table-names)))) > (with-current-buffer (get-buffer-create "*Abbrevs*") > (erase-buffer) > - (if local > + (if (eq how 'local) > (insert-abbrev-table-description > (abbrev-table-name local-table) t) > - (dolist (table abbrev-table-name-list) > + (dolist (table tables) > (insert-abbrev-table-description table t))) > (goto-char (point-min)) > (set-buffer-modified-p nil) > @@ -140,10 +154,11 @@ > (use-local-map edit-abbrevs-map) > (run-mode-hooks 'edit-abbrevs-mode-hook)) > > -(defun edit-abbrevs () > +(defun edit-abbrevs (&optional all) > "Alter abbrev definitions by editing a list of them. > Selects a buffer containing a list of abbrev definitions. > -You can edit them and type \\\\[edit-abbrevs-redefine] to redefine abbrevs > +Use \\[universal-argument] to include empty abbrev tables. You can edit > +them and type \\\\[edit-abbrevs-redefine] to redefine abbrevs > according to your editing. > Buffer contains a header line for each abbrev table, > which is the abbrev table name in parentheses. > @@ -152,8 +167,8 @@ > where NAME and EXPANSION are strings with quotes, > USECOUNT is an integer, and HOOK is any valid function > or may be omitted (it is usually omitted)." > - (interactive) > - (switch-to-buffer (prepare-abbrev-list-buffer))) > + (interactive "P") > + (switch-to-buffer (prepare-abbrev-list-buffer (and all 'all)))) > > (defun edit-abbrevs-redefine () > "Redefine abbrevs according to current buffer contents." > @@ -225,7 +240,8 @@ > abbrev-file-name))) > (or (and file (> (length file) 0)) > (setq file abbrev-file-name)) > - (let ((coding-system-for-write 'utf-8)) > + (let ((coding-system-for-write 'utf-8) > + (tables (abbrev-nonempty-table-names t))) > (with-temp-buffer > (dolist (table > ;; We sort the table in order to ease the automatic > @@ -234,10 +250,9 @@ > ;; user keeps their home directory in a revision > ;; control system, and is therefore keeping multiple > ;; slightly-differing copies loosely synchronized. > - (sort (copy-sequence abbrev-table-name-list) > - (lambda (s1 s2) > - (string< (symbol-name s1) > - (symbol-name s2))))) > + (sort tables (lambda (s1 s2) > + (string< (symbol-name s1) > + (symbol-name s2))))) > (insert-abbrev-table-description table nil)) > (when (unencodable-char-position (point-min) (point-max) 'utf-8) > (setq coding-system-for-write > @@ -420,6 +435,18 @@ > (and (vectorp object) > (numberp (abbrev-table-get object :abbrev-table-modiff)))) > > +(defun abbrev-table-empty-p (object&optional ignore-system) > + "Return nil if there are no abbrev symbols in OBJECT. > +If IGNORE-SYSTEM is non-nil, system definitions are ignored." > + (unless (abbrev-table-p object) > + (error "Non abbrev table object")) > + (not (catch 'some > + (mapatoms (lambda (abbrev) > + (unless (or (zerop (length (symbol-name abbrev))) > + (and ignore-system (abbrev-get abbrev :system))) > + (throw 'some t))) > + object)))) > + > (defvar global-abbrev-table (make-abbrev-table) > "The abbrev table whose abbrevs affect all buffers. > Each buffer may also have a local abbrev table. > > > > > > Leo Hi Leo, just an abstract reasoning: don't change things you are not compelled to. Or to say: unless there is a reason for it. An empty table doesn't take considerable space nor time. OTOH when changing a thing, always remains a certain risk to break something. As said, just abtract reasoning. Don't see a real danger here. Cheers Andreas From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 27 16:35:46 2011 Received: (at 5937) by debbugs.gnu.org; 27 Mar 2011 20:35:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3wgc-0005Pb-HF for submit@debbugs.gnu.org; Sun, 27 Mar 2011 16:35:46 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3wgb-0005PP-5c for 5937@debbugs.gnu.org; Sun, 27 Mar 2011 16:35:45 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAGSej01MCqRC/2dsb2JhbAClUHiIa7cahWkElgU X-IronPort-AV: E=Sophos;i="4.63,251,1299474000"; d="scan'208";a="98273008" Received: from 76-10-164-66.dsl.teksavvy.com (HELO pastel.home) ([76.10.164.66]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 27 Mar 2011 16:35:39 -0400 Received: by pastel.home (Postfix, from userid 20848) id E941058EBD; Sun, 27 Mar 2011 16:35:38 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Sun, 27 Mar 2011 16:35:38 -0400 In-Reply-To: (Leo's message of "Sun, 27 Mar 2011 13:09:42 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) >> Actually, having tried it now for a while I do have an objection: it >> makes it harder to add entries to an abbrev-table if that table >> is empty. >> >> So I think a better option is to sort the tables such that empty tables >> are pushed to the end. > I propose we allow C-u M-x edit-abbrevs to include all abbrev tables but > default to include only nonempty tables. I don't think we need such a thing. We just need to make it clear what those empty tables mean and keep them out of the way. I.e. move them to the end of the buffer and add a comment before them explaining that these are currently empty. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 27 16:40:24 2011 Received: (at submit) by debbugs.gnu.org; 27 Mar 2011 20:40:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3wl5-0005X8-Ml for submit@debbugs.gnu.org; Sun, 27 Mar 2011 16:40:23 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q3wl3-0005Wx-0Z for submit@debbugs.gnu.org; Sun, 27 Mar 2011 16:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3wkw-0006OT-N8 for submit@debbugs.gnu.org; Sun, 27 Mar 2011 16:40:15 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:38245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3wkw-0006OP-Ic for submit@debbugs.gnu.org; Sun, 27 Mar 2011 16:40:14 -0400 Received: from [140.186.70.92] (port=43367 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q3wkv-0006fO-G4 for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 16:40:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3wku-0006NU-Cv for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 16:40:13 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183]:15843 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3wku-0006NN-AP for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 16:40:12 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAI+fj01MCqRC/2dsb2JhbAClUHiIa7chhWkElgU X-IronPort-AV: E=Sophos;i="4.63,251,1299474000"; d="scan'208";a="98273374" Received: from 76-10-164-66.dsl.teksavvy.com (HELO pastel.home) ([76.10.164.66]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 27 Mar 2011 16:40:11 -0400 Received: by pastel.home (Postfix, from userid 20848) id DA9A558EBD; Sun, 27 Mar 2011 16:40:10 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Sun, 27 Mar 2011 16:40:10 -0400 In-Reply-To: (Leo's message of "Tue, 27 Apr 2010 11:32:33 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.1 (----) > C-x C-s usually means things have been saved and are safe unless > something happen to the harddisk. > In abbrevs it is not. And sometimes one doesn't get the chance to > actually save it because emacs crashes halfway. > I would propose separating C-x C-s and C-c C-c. C-x C-s should stay > close to the global key binding. You mean keep C-c C-c bound to edit-abbrevs-redefine, but change C-x C-s to call write-abbrev-file? Sounds good (tho it'll have to call edit-abbrevs-redefine before write-abbrev-file beforehand, of course). Oh and by the way: the abbrev.el file should be (slowly) fixed to use the "abbrev-" prefix for all functions and commands, so whenever you introduce a new function/command/variable please use this prefix rather than the previous style of -abbrev-. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 27 23:38:58 2011 Received: (at submit) by debbugs.gnu.org; 28 Mar 2011 03:38:58 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q43I9-0007oe-9b for submit@debbugs.gnu.org; Sun, 27 Mar 2011 23:38:57 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q43I6-0007oR-Og for submit@debbugs.gnu.org; Sun, 27 Mar 2011 23:38:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q43I0-00020T-JH for submit@debbugs.gnu.org; Sun, 27 Mar 2011 23:38:49 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:45237) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q43I0-00020P-H5 for submit@debbugs.gnu.org; Sun, 27 Mar 2011 23:38:48 -0400 Received: from [140.186.70.92] (port=44116 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q43Hz-00072w-Eo for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 23:38:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q43Hy-0001zw-1X for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 23:38:47 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:37550) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q43Hx-0001zU-Uh for bug-gnu-emacs@gnu.org; Sun, 27 Mar 2011 23:38:45 -0400 Received: by iwg8 with SMTP id 8so3382330iwg.0 for ; Sun, 27 Mar 2011 20:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=woB//HCJJ+Q5Q2K7q0t9Mk0/n7tPNzrpfNIlNJcq7wo=; b=I9J5JW0SGX8y2cXXziiwDugfHJGt0gzfUkKxGUyf3kfjSwDWxGLzPkAJ3Si6Caktuw bpnrg267S+WMdeWo2HIUpGnCGu8EwofvIykwWXDEzBPtk/tm8GrZyxRwBI8WTCRunrAl XrIC2SG7BxDGnjED1ZTfbh1nTGpUJuyl64BiU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; b=EYCDmBq8fUfkzPbX4yun4ySK7AzbHCWXZvJpyhasFCaT92jhEd8Wud4YbWKRbL2/y8 VOKtPq1/efLLzohuxsRVz+p8VqB7RnEEQ4tXvYBE6nWy17TjrPsXJD/5bj0hyGj3ZI5Q 6jAUf079o9xwLIeO3nq4mhnKkoq4KiMay/USo= Received: by 10.42.246.72 with SMTP id lx8mr5862362icb.276.1301283524700; Sun, 27 Mar 2011 20:38:44 -0700 (PDT) Received: from Victoria.local (th041068.ip.tsinghua.edu.cn [59.66.41.68]) by mx.google.com with ESMTPS id g17sm2643378ibb.6.2011.03.27.20.38.40 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 20:38:43 -0700 (PDT) From: Leo To: Andreas =?iso-8859-1?Q?R=F6hler?= Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: <4D8F752C.2000605@easy-emacs.de> Date: Mon, 28 Mar 2011 11:38:35 +0800 In-Reply-To: <4D8F752C.2000605@easy-emacs.de> ("Andreas =?iso-8859-1?Q?R?= =?iso-8859-1?Q?=F6hler=22's?= message of "Sun, 27 Mar 2011 19:34:36 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -5.2 (-----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.2 (-----) On 2011-03-28 01:34 +0800, Andreas R=F6hler wrote: > just an abstract reasoning: don't change things you are not compelled > to. Or to say: unless there is a reason for it. In practice and in my currently running emacs, there are 68 abbrev tables breaking down to: 57 empty + 4 with pure system abbrevs + 7 with user defined abbrevs. Obviously the 57 empty tables which, in my case, never get used at all get in the way pretty badly. Leo From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 00:03:39 2011 Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 04:03:40 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q43g3-0008Lw-1j for submit@debbugs.gnu.org; Mon, 28 Mar 2011 00:03:39 -0400 Received: from mail-pz0-f44.google.com ([209.85.210.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q43g1-0008Lh-Ec for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 00:03:38 -0400 Received: by pzk30 with SMTP id 30so457187pzk.3 for <5937@debbugs.gnu.org>; Sun, 27 Mar 2011 21:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=5imKLcrYT1CiWo8hiZnJs5hsehOb5LJ0oVQKvMHZPzA=; b=UYKFMBXf9YBC8q2LMz8U+UsAK3h8A7efNvhPDKJxJ58AaPBWYU9vdDZ8Ei/8W29FSe vk3gVoPyseac0PXbAcd/ly7/TjeJRn8UThUoHJu8qtWyiDEyJ/5NFHXpbEumdIZ7WVzH 7lNkGHBpuGDhV6aoyk791G89uZ6k+pW71Cj7c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=ATdxXqntzuAONATQW4KU9FNG/e+YzZnPO8Sob+WSq+KiQSGVOs/mg/btDMI6dSpYcO r4fFB4vMwtgdgAn0XTpx3EcAXVJfvs6juAoNVWy482YYI8YMJPLQro/eztnGBQqOT++R YD52yHYaWVGkxQ4bSSC1UJ2DHGs0NEqU3Md/U= Received: by 10.143.35.10 with SMTP id n10mr3398515wfj.429.1301285011461; Sun, 27 Mar 2011 21:03:31 -0700 (PDT) Received: from Victoria.local (th041068.ip.tsinghua.edu.cn [59.66.41.68]) by mx.google.com with ESMTPS id o11sm5328971wfa.0.2011.03.27.21.03.27 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 21:03:30 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Mon, 28 Mar 2011 12:03:22 +0800 In-Reply-To: (Stefan Monnier's message of "Sun, 27 Mar 2011 16:35:38 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.1 (----) On 2011-03-28 04:35 +0800, Stefan Monnier wrote: > I don't think we need such a thing. We just need to make it clear what > those empty tables mean and keep them out of the way. I.e. move them to > the end of the buffer and add a comment before them explaining that > these are currently empty. OK let's do this. I didn't insert a line explaining empty tables because they are obvious (See this screenshot: http://imgur.com/zCegB.png). (BTW, after looking at that screenshot I realised Makefile mode introduces 6 abbrev tables; amazing.) Let me know if you are OK with this patch. Thanks, Leo === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-03-22 15:38:40 +0000 +++ lisp/abbrev.el 2011-03-28 03:52:49 +0000 @@ -123,8 +123,13 @@ (if local (insert-abbrev-table-description (abbrev-table-name local-table) t) - (dolist (table abbrev-table-name-list) - (insert-abbrev-table-description table t))) + (let (empty-tables) + (dolist (table abbrev-table-name-list) + (if (abbrev-table-empty-p (symbol-value table)) + (push table empty-tables) + (insert-abbrev-table-description table t))) + (dolist (table (nreverse empty-tables)) + (insert-abbrev-table-description table t)))) (goto-char (point-min)) (set-buffer-modified-p nil) (edit-abbrevs-mode) @@ -420,6 +425,18 @@ (and (vectorp object) (numberp (abbrev-table-get object :abbrev-table-modiff)))) +(defun abbrev-table-empty-p (object &optional ignore-system) + "Return nil if there are no abbrev symbols in OBJECT. +If IGNORE-SYSTEM is non-nil, system definitions are ignored." + (unless (abbrev-table-p object) + (error "Non abbrev table object")) + (not (catch 'some + (mapatoms (lambda (abbrev) + (unless (or (zerop (length (symbol-name abbrev))) + (and ignore-system (abbrev-get abbrev :system))) + (throw 'some t))) + object)))) + (defvar global-abbrev-table (make-abbrev-table) "The abbrev table whose abbrevs affect all buffers. Each buffer may also have a local abbrev table. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 00:46:03 2011 Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 04:46:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q44L5-0000qR-0c for submit@debbugs.gnu.org; Mon, 28 Mar 2011 00:46:03 -0400 Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q44L3-0000py-Sa for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 00:46:02 -0400 Received: by iwn39 with SMTP id 39so2640647iwn.3 for <5937@debbugs.gnu.org>; Sun, 27 Mar 2011 21:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=VcxFuFW10ejc/JL49WEIp5u62l+XKjsGmubH+XRPYNw=; b=QXuy8Zy8546IBM13EsMlfUftebsumPHGOe7b8h5WvutUtuNvgg+EWSUwt5s8DRiyF9 I0J2p33CCJPBz0JtUp5qHwXkN8iJpjAdgwwYPu6QhNpmmuztZr0d11+rAhklRFMFfKX5 0JLshAGvl2uGeZv9esvvNNRilFGT4MA+e9uMw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=SFfD4sNgvegl1Of44+ZFM13GTRCMPf7A9kDMvjwGFbMsYpUqpjplZjYb4McpxqOMcd mV7OqAifs1mpoY0xDb1EqQTColVHgCVThvjjBcTfxTqi8S7sla/Yr59gnRDg7TtOhDA9 do6D0HNoppPj3AZTi1QI9/a8+TjMmJEuQZu2A= Received: by 10.42.138.4 with SMTP id a4mr6004157icu.258.1301287556230; Sun, 27 Mar 2011 21:45:56 -0700 (PDT) Received: from Victoria.local (th041068.ip.tsinghua.edu.cn [59.66.41.68]) by mx.google.com with ESMTPS id gy41sm2676133ibb.56.2011.03.27.21.45.52 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2011 21:45:55 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Mon, 28 Mar 2011 12:45:47 +0800 In-Reply-To: (Stefan Monnier's message of "Sun, 27 Mar 2011 16:40:10 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) On 2011-03-28 04:40 +0800, Stefan Monnier wrote: > You mean keep C-c C-c bound to edit-abbrevs-redefine, but change C-x C-s > to call write-abbrev-file? Sounds good (tho it'll have to call > edit-abbrevs-redefine before write-abbrev-file beforehand, of course). > Oh and by the way: the abbrev.el file should be (slowly) fixed to use > the "abbrev-" prefix for all functions and commands, so whenever you > introduce a new function/command/variable please use this prefix rather > than the previous style of -abbrev-. How about this patch? === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-03-22 15:38:40 +0000 +++ lisp/abbrev.el 2011-03-28 04:42:26 +0000 @@ -65,7 +65,8 @@ (defvar edit-abbrevs-map (let ((map (make-sparse-keymap))) - (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) + (define-key map "\C-x\C-s" 'abbrev-save-buffer) + (define-key map "\C-x\C-w" 'write-abbrev-file) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) map) "Keymap used in `edit-abbrevs'.") @@ -211,13 +212,14 @@ ;(interactive "fRead abbrev file: ") (read-abbrev-file file t)) -(defun write-abbrev-file (&optional file) +(defun write-abbrev-file (&optional file verbose) "Write all user-level abbrev definitions to a file of Lisp code. This does not include system abbrevs; it includes only the abbrev tables listed in listed in `abbrev-table-name-list'. The file written can be loaded in another session to define the same abbrevs. The argument FILE is the file name to write. If omitted or nil, the file -specified in `abbrev-file-name' is used." +specified in `abbrev-file-name' is used. +If VERBOSE is non-nil, display a message where abbrevs have been saved." (interactive (list (read-file-name "Write abbrev file: " @@ -225,6 +227,7 @@ abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) + (edit-abbrevs-redefine) (let ((coding-system-for-write 'utf-8)) (with-temp-buffer (dolist (table @@ -247,7 +250,14 @@ 'emacs-mule))) (goto-char (point-min)) (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) - (write-region nil nil file nil 0)))) + (write-region nil nil file nil (and (not verbose) 0))))) + +(defun abbrev-save-buffer () + "Save all user-level abbrev definitions in current buffer. +The file name to use is `abbrev-file-name'." + (interactive) + (write-abbrev-file abbrev-file-name t)) + (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point. From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 09:58:19 2011 Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 13:58:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4CxV-0005Mb-N0 for submit@debbugs.gnu.org; Mon, 28 Mar 2011 09:58:18 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4CxT-0005MO-G6 for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 09:58:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAE6TkE1MCqRC/2dsb2JhbAClPniIa7oNhWkElgU X-IronPort-AV: E=Sophos;i="4.63,255,1299474000"; d="scan'208";a="98345314" Received: from 76-10-164-66.dsl.teksavvy.com (HELO ceviche.home) ([76.10.164.66]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 28 Mar 2011 09:58:09 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 3E2E5660F8; Mon, 28 Mar 2011 09:58:09 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Mon, 28 Mar 2011 09:58:09 -0400 In-Reply-To: (Leo's message of "Mon, 28 Mar 2011 12:45:47 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) >> You mean keep C-c C-c bound to edit-abbrevs-redefine, but change C-x C-s >> to call write-abbrev-file? Sounds good (tho it'll have to call >> edit-abbrevs-redefine before write-abbrev-file beforehand, of course). >> Oh and by the way: the abbrev.el file should be (slowly) fixed to use >> the "abbrev-" prefix for all functions and commands, so whenever you >> introduce a new function/command/variable please use this prefix rather >> than the previous style of -abbrev-. > How about this patch? > @@ -225,6 +227,7 @@ > abbrev-file-name))) > (or (and file (> (length file) 0)) > (setq file abbrev-file-name)) > + (edit-abbrevs-redefine) > (let ((coding-system-for-write 'utf-8)) > (with-temp-buffer > (dolist (table > @@ -247,7 +250,14 @@ > 'emacs-mule))) > (goto-char (point-min)) > (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) > - (write-region nil nil file nil 0)))) > + (write-region nil nil file nil (and (not verbose) 0))))) > + > +(defun abbrev-save-buffer () > + "Save all user-level abbrev definitions in current buffer. > +The file name to use is `abbrev-file-name'." > + (interactive) > + (write-abbrev-file abbrev-file-name t)) write-abbrev-file may be called from a non-"edit-abbrevs" buffer (e.g. from save-some-buffer), so I think that calling edit-abbrevs-redefine from it is problematic. Is there a particular reason why you put the call to edit-abbrevs-redefine in write-abbrev-file rather than in abbrev-save-buffer. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 10:02:35 2011 Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 14:02:35 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4D1d-0005Su-UC for submit@debbugs.gnu.org; Mon, 28 Mar 2011 10:02:34 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4D1c-0005Sf-4h for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 10:02:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAIGUkE1MCqRC/2dsb2JhbAClPniIa7l/hWkEk3eCDg X-IronPort-AV: E=Sophos;i="4.63,255,1299474000"; d="scan'208";a="98345874" Received: from 76-10-164-66.dsl.teksavvy.com (HELO ceviche.home) ([76.10.164.66]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 28 Mar 2011 10:02:15 -0400 Received: by ceviche.home (Postfix, from userid 20848) id C5D1D660F8; Mon, 28 Mar 2011 10:02:14 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Mon, 28 Mar 2011 10:02:14 -0400 In-Reply-To: (Leo's message of "Mon, 28 Mar 2011 12:03:22 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) >> I don't think we need such a thing. We just need to make it clear what >> those empty tables mean and keep them out of the way. I.e. move them to >> the end of the buffer and add a comment before them explaining that >> these are currently empty. > OK let's do this. I didn't insert a line explaining empty tables because > they are obvious (See this screenshot: http://imgur.com/zCegB.png). > (BTW, after looking at that screenshot I realised Makefile mode > introduces 6 abbrev tables; amazing.) > Let me know if you are OK with this patch. The patch looks good, thank you, please install it. I'd still like to see a comment added, but there are many other things that would be good to add to edit-abbrevs (e.g. highlighting, or an actually useful C-h m output explaining the format expected by C-c C-c, ...). Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 10:27:13 2011 Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 14:27:13 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4DPV-000628-EN for submit@debbugs.gnu.org; Mon, 28 Mar 2011 10:27:13 -0400 Received: from mail-gx0-f172.google.com ([209.85.161.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4DPT-00061v-NG for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 10:27:12 -0400 Received: by gxk19 with SMTP id 19so1131091gxk.3 for <5937@debbugs.gnu.org>; Mon, 28 Mar 2011 07:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=5NZLoz6WOZ/KYLKJ5I+mK3d36EEpOcbkV3X+DI53oYc=; b=kCC6cTDmwH7Vo02SY8CrASjOW282hrhLUNsT13Udd49CzD2ut20T/cqLwFDMFXLSkq o/PEwTQy4rkmzkuDi/x3tLaTozv+xQ6hgkgX+0ge272iRATIvht3W1DivC7ubIBO4XzS OTq58JLOzvEywpFXrCEKqlLsS8XIOWZ8JNZu8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=MuervJqu8Jqe7r1Xxb6+iTmrRzPHVc9fyBO4RvuGMvJLQgvPvAbZVfoHFX5Js6OU3D VtruTqr/FTiUWx8s/bqifKiHUdxzDsLwS2W6X0LKxL43dqNUmGohKKETR9TqHl9b3qC4 1mCgho2kRmSY7sSEFfWhdnTLwKrDftYp4fyRA= Received: by 10.42.239.74 with SMTP id kv10mr246542icb.402.1301322415857; Mon, 28 Mar 2011 07:26:55 -0700 (PDT) Received: from Victoria.local (th041112.ip.tsinghua.edu.cn [59.66.41.112]) by mx.google.com with ESMTPS id i20sm2983317iby.48.2011.03.28.07.26.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Mar 2011 07:26:54 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Mon, 28 Mar 2011 22:26:43 +0800 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Mar 2011 09:58:09 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) On 2011-03-28 21:58 +0800, Stefan Monnier wrote: > write-abbrev-file may be called from a non-"edit-abbrevs" buffer > (e.g. from save-some-buffer), so I think that calling > edit-abbrevs-redefine from it is problematic. Is there a particular > reason why you put the call to edit-abbrevs-redefine in > write-abbrev-file rather than in abbrev-save-buffer. Good point. I missed it. I want C-x C-w to also redefine the abbrevs if it is called in that editing buffer. Do you mind if I do something like the following in write-abbrev-file: (and (derived-mode-p 'edit-abbrevs-mode) (edit-abbrevs-redefine)) Leo -- Oracle is the new evil From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 10:40:20 2011 Received: (at 5937) by debbugs.gnu.org; 28 Mar 2011 14:40:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4DcB-00079g-Uu for submit@debbugs.gnu.org; Mon, 28 Mar 2011 10:40:20 -0400 Received: from mail-gx0-f172.google.com ([209.85.161.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Dc8-00079S-Bx for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 10:40:17 -0400 Received: by gxk19 with SMTP id 19so1136826gxk.3 for <5937@debbugs.gnu.org>; Mon, 28 Mar 2011 07:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=OhIwzCExDMDI+4is8rp9V0oLmphvViwpi4zIVlK18uw=; b=bkI0z230uZgcz2Vh0bL6gLa0ME0YsVQ42sq0bXjQR642u60yRY9uGTGhoCzVfxhX1d MICo8ci9311In5tSV1k1zmdA9w359U3H3OOloTJKsr44MN0QQYRZXvr7I0uEBmBP42Ll 9OAMOHJAMgOcBOw1wH4AZsd2YZJg30ce811pc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=aPIj6uUPch9/ugtCtwuPb9APi4peW7wkR22BGEggZ6shRl7Jre0RFJMm7HU4NhKrSB VWuLdWBFu+p8pHbftMTtzuTn6DNIYfcT69ee0laoAQ3pROUM/dxRKy3d2/0ZejQPPKoy uQoFFcpBdpu/Dn+U50GvdZUp6Qws2TbxTVBkU= Received: by 10.43.63.66 with SMTP id xd2mr7166444icb.76.1301323210771; Mon, 28 Mar 2011 07:40:10 -0700 (PDT) Received: from Victoria.local (th041112.ip.tsinghua.edu.cn [59.66.41.112]) by mx.google.com with ESMTPS id c4sm2847620ict.7.2011.03.28.07.40.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Mar 2011 07:40:08 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Mon, 28 Mar 2011 22:40:02 +0800 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Mar 2011 10:02:14 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) On 2011-03-28 22:02 +0800, Stefan Monnier wrote: > The patch looks good, thank you, please install it. Installed in trunk. > I'd still like to see a comment added, but there are many other things > that would be good to add to edit-abbrevs (e.g. highlighting, or an > actually useful C-h m output explaining the format expected by C-c > C-c, ...). `highlighting' would be good. I think the comment is best inserted when it has its own face. At the moment it looks out of place. Leo From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 20:31:33 2011 Received: (at 5937) by debbugs.gnu.org; 29 Mar 2011 00:31:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4MqL-0004qb-Bz for submit@debbugs.gnu.org; Mon, 28 Mar 2011 20:31:33 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4MqI-0004qN-WA for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 20:31:31 -0400 Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id p2T0VO6v014102; Mon, 28 Mar 2011 20:31:25 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 4750666350; Mon, 28 Mar 2011 11:09:34 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Mon, 28 Mar 2011 11:09:34 -0400 In-Reply-To: (Leo's message of "Mon, 28 Mar 2011 22:26:43 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3810=0 X-NAI-Spam-Version: 2.2.0.9286 : core <3810> : streams <614376> : uri <837528> X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.5 (-) >> write-abbrev-file may be called from a non-"edit-abbrevs" buffer >> (e.g. from save-some-buffer), so I think that calling >> edit-abbrevs-redefine from it is problematic. Is there a particular >> reason why you put the call to edit-abbrevs-redefine in >> write-abbrev-file rather than in abbrev-save-buffer. > Good point. I missed it. I want C-x C-w to also redefine the abbrevs if > it is called in that editing buffer. Do you mind if I do something like > the following in write-abbrev-file: > (and (derived-mode-p 'edit-abbrevs-mode) > (edit-abbrevs-redefine)) I'd rather call edit-abbrevs-redefine from the new command you'll bind to C-x C-w. Stefan From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 20:35:36 2011 Received: (at 5937) by debbugs.gnu.org; 29 Mar 2011 00:35:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4MuG-0004wS-Jg for submit@debbugs.gnu.org; Mon, 28 Mar 2011 20:35:36 -0400 Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4MuE-0004wG-L3 for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 20:35:35 -0400 Received: by iwn39 with SMTP id 39so3621012iwn.3 for <5937@debbugs.gnu.org>; Mon, 28 Mar 2011 17:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=6Q+Sn6ZxL7U2OWVqQMVk6z8gNX0H0yZuHElSc34tnXQ=; b=mL8IbxWNiCOiHZ2yuva+hldg1VGoTSnOeIH0XNjKq0K8YCVYwcFoa8xt5QdPRvN+64 jalalUlgmuRXZlGtBBAISF1149vQoKOVadie6fK1S/5KDFGp/dEJ/zDWTFMUPLy9ti0q 1t/A5Ov59WcBBbm7uM2diqACNy3qx7hO/KE24= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=Hx7L7neetRoSB5zNMwRYfi+qvYVppl3+Dw3BNI7aNknn04BxjGHBgFrHeZlH3pejAp VEOJS/yjMf0+uTqN7c5TXCBN9xIYavwjBuGFJQ9XJkmaSWQZfaR8TKEcFck1xaN8qA2h 0FumUgjAhQvGdZGVCclgNcYE2sfSZCWwWe2Rw= Received: by 10.43.69.199 with SMTP id yd7mr1154203icb.370.1301358928897; Mon, 28 Mar 2011 17:35:28 -0700 (PDT) Received: from Victoria.local (th041092.ip.tsinghua.edu.cn [59.66.41.92]) by mx.google.com with ESMTPS id he40sm3270259ibb.67.2011.03.28.17.35.26 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Mar 2011 17:35:27 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Tue, 29 Mar 2011 08:35:22 +0800 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Mar 2011 11:09:34 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) On 2011-03-28 23:09 +0800, Stefan Monnier wrote: > I'd rather call edit-abbrevs-redefine from the new command you'll bind > to C-x C-w. Do you mean 'C-x C-s'? C-x C-w is bound to write-abbrev-file in the patch? If so, I guess it makes sense not to bind C-x C-w. Leo From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 28 23:31:22 2011 Received: (at 5937) by debbugs.gnu.org; 29 Mar 2011 03:31:23 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4PeM-0001rB-6G for submit@debbugs.gnu.org; Mon, 28 Mar 2011 23:31:22 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4PeK-0001qz-6j for 5937@debbugs.gnu.org; Mon, 28 Mar 2011 23:31:20 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEADdRkU1MCqRC/2dsb2JhbAClSHiIdrwkhWoElgY X-IronPort-AV: E=Sophos;i="4.63,259,1299474000"; d="scan'208";a="98452033" Received: from 76-10-164-66.dsl.teksavvy.com (HELO ceviche.home) ([76.10.164.66]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 28 Mar 2011 23:31:14 -0400 Received: by ceviche.home (Postfix, from userid 20848) id BD5E6660C7; Mon, 28 Mar 2011 23:31:13 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Mon, 28 Mar 2011 23:31:13 -0400 In-Reply-To: (Leo's message of "Tue, 29 Mar 2011 08:35:22 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) >> I'd rather call edit-abbrevs-redefine from the new command you'll bind >> to C-x C-w. > Do you mean 'C-x C-s'? C-x C-w is bound to write-abbrev-file in the > patch? If so, I guess it makes sense not to bind C-x C-w. Oh, I didn't notice this part of the patch. So I guess what I'm suggesting is to create a new command for use in C-x C-w which calls edit-abbrevs-redefine and then calls interactively write-abbrev-file. The issue with write-abbrev-file is that it's called from save-some-buffers so we can't/shouldn't bind it to edit-abbrevs. Maybe another solution is to change edit-abbrevs-mode so that save-buffer and write-file work in it by calling internally write-abbrev-file. Note sure if that can be made to work without major surgery, tho (write-region-annotate-functions could do some of it, but I think the lack of buffer-file-name setting will get in the way, so we'd have to change edit-abbrevs so that it sets buffer-file-name and is really turned into a major mode to edit the .abbrev-defs file, which seems like a fairly different beast). Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 00:42:01 2011 Received: (at 5937) by debbugs.gnu.org; 29 Mar 2011 04:42:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Qki-0003Tf-Nt for submit@debbugs.gnu.org; Tue, 29 Mar 2011 00:42:01 -0400 Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4Qkf-0003TT-TA for 5937@debbugs.gnu.org; Tue, 29 Mar 2011 00:41:58 -0400 Received: by iwn39 with SMTP id 39so3784678iwn.3 for <5937@debbugs.gnu.org>; Mon, 28 Mar 2011 21:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=+JLIx1g+5BJGsoBpMgXu3SQrW1KmppjEzehiIPBbh0E=; b=Taa8IQed3a1XiyMi/JNfycl4N/MYFpqOgQQY3xb5HxuV1NlZdHbTqtWwbrlYpjtW9h kG35a2SoD4w/VWM8vQsDpkgBfyXlnAchZY+ipm/WxHjQP+mOX9izuUbPNWJFZWP4nypr I90TXKP8lcPi3yzW9DCiLuwz1q7FFF5aGCl5w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=ZpceyODVNvPuxSYbZFd/zJMZMWG92Z3TQmzoT/gEXjWd4YORGs75rEPmQ667sO/sDZ n0NYbEguGg7dCa/r7TsI/YufkeV571XTjLr7D7ZphuopfNJwwnLu3W50EIcfKhfdVgQ0 5YDyXd+kaFHgqmaMVMWRdNNflGzJIs/NdJJ5c= Received: by 10.42.157.193 with SMTP id e1mr8180412icx.178.1301373712158; Mon, 28 Mar 2011 21:41:52 -0700 (PDT) Received: from Victoria.local ([114.249.26.81]) by mx.google.com with ESMTPS id y10sm3382812iba.29.2011.03.28.21.41.48 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Mar 2011 21:41:51 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Tue, 29 Mar 2011 12:41:44 +0800 In-Reply-To: (Stefan Monnier's message of "Mon, 28 Mar 2011 23:31:13 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: 5937 Cc: 5937@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.1 (----) On 2011-03-29 11:31 +0800, Stefan Monnier wrote: > Oh, I didn't notice this part of the patch. So I guess what I'm > suggesting is to create a new command for use in C-x C-w which calls > edit-abbrevs-redefine and then calls interactively write-abbrev-file. > The issue with write-abbrev-file is that it's called from > save-some-buffers so we can't/shouldn't bind it to edit-abbrevs. Thanks for that. I forgot write-abbrev-file is also called elsewhere. How about this patch? diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 0a3e1fd1..b1d9e024 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -73,7 +73,8 @@ (put 'abbrev-mode 'safe-local-variable 'booleanp) (defvar edit-abbrevs-map (let ((map (make-sparse-keymap))) - (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) + (define-key map "\C-x\C-s" 'abbrev-save-buffer) + (define-key map "\C-x\C-w" 'abbrev-save-to-file) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) map) "Keymap used in `edit-abbrevs'.") @@ -224,13 +225,15 @@ (defun quietly-read-abbrev-file (&optional file) ;(interactive "fRead abbrev file: ") (read-abbrev-file file t)) -(defun write-abbrev-file (&optional file) +(defun write-abbrev-file (&optional file verbose) "Write all user-level abbrev definitions to a file of Lisp code. This does not include system abbrevs; it includes only the abbrev tables listed in listed in `abbrev-table-name-list'. The file written can be loaded in another session to define the same abbrevs. The argument FILE is the file name to write. If omitted or nil, the file -specified in `abbrev-file-name' is used." +specified in `abbrev-file-name' is used. +If VERBOSE is non-nil, display a message indicating where abbrevs +have been saved." (interactive (list (read-file-name "Write abbrev file: " @@ -260,7 +263,28 @@ (defun write-abbrev-file (&optional file) 'emacs-mule))) (goto-char (point-min)) (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) - (write-region nil nil file nil 0)))) + (write-region nil nil file nil (and (not verbose) 0))))) + +(defun abbrev-save-buffer () + "Save all user-level abbrev definitions in current buffer. +The saved abbrevs are written to the file specified by +`abbrev-file-name'." + (interactive) + (and (derived-mode-p 'edit-abbrevs-mode) + (edit-abbrevs-redefine)) + (write-abbrev-file abbrev-file-name t)) + +(defun abbrev-save-to-file (file) + "Save all user-level abbrev definitions in current buffer to FILE." + (interactive + (list (read-file-name "Save abbrevs to file: " + (file-name-directory + (expand-file-name abbrev-file-name)) + abbrev-file-name))) + (and (derived-mode-p 'edit-abbrevs-mode) + (edit-abbrevs-redefine)) + (write-abbrev-file file t)) + (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point. > Maybe another solution is to change edit-abbrevs-mode so that > save-buffer and write-file work in it by calling internally > write-abbrev-file. Note sure if that can be made to work without major > surgery, tho (write-region-annotate-functions could do some of it, but > I think the lack of buffer-file-name setting will get in the way, so > we'd have to change edit-abbrevs so that it sets buffer-file-name and > is really turned into a major mode to edit the .abbrev-defs file, which > seems like a fairly different beast). > > > Stefan This isn't cleaner at the moment. So probably leave it for future improvement. Leo From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 01:16:51 2011 Received: (at submit) by debbugs.gnu.org; 29 Mar 2011 05:16:51 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4RIQ-0004EY-C1 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 01:16:50 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4RIO-0004EK-NO for submit@debbugs.gnu.org; Tue, 29 Mar 2011 01:16:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4RII-0002gK-O8 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 01:16:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_NUMERIC_HELO, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:47573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4RII-0002gG-Lj for submit@debbugs.gnu.org; Tue, 29 Mar 2011 01:16:42 -0400 Received: from [140.186.70.92] (port=36813 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4RIH-0001wd-KF for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 01:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4RIG-0002g1-CW for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 01:16:41 -0400 Received: from lo.gmane.org ([80.91.229.12]:32832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4RIF-0002fv-Qd for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 01:16:40 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q4RIC-0005I4-Hx for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 07:16:37 +0200 Received: from 114.249.26.81 ([114.249.26.81]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Mar 2011 07:16:36 +0200 Received: from sdl.web by 114.249.26.81 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 Mar 2011 07:16:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Date: Tue, 29 Mar 2011 13:16:23 +0800 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 114.249.26.81 Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoBAMAAAB+0KVeAAAAMFBMVEUaFRZLMy1dTENxVzKQ WiCrXQ97cmO/dSqSh3akjGTApXy5sJ7Sxo/Sz8Xo6eP9//xJbkruAAAAAWJLR0QAiAUdSAAAAAlw SFlzAAACxQAAAsUBidZ/7wAAAAd0SU1FB9cBBwMJOwHXewoAAAIBSURBVCjPVdNBiNNAFADQ6J4F x3hThHZBBC+WCFI8SS0iezRDcMHLHkLAg6gJH/fgYQ9xYlj2sLK4KHgqCgXFhda2Idmr4kkQPZQ0 nkQMbTypbMmMM2m7ZgYSmMef/5OZPwo7HFnx3uKPcmj0Dht1LWZJ+Hvr7dIFZXRUwl9VRTuuKDJ+ U44gjscknK4hhJaCkYRsWjmBtLqXlJAG2wipNe18OZJu1BBq1E8xafl4s6Jq2mUZGftU1y7CCxnp FVUDWJXx4C66BKBnErbuoaYNtoRTu6EZBsCbMn7W+5qOAR6WvxNOby9jHWC9hAf3n304CdiAByXs 3Nh9roLDkyb/sWV712vYwaLSAn8CPMHIAAzOPDKP2COAFm4Y4ODVWc6xG7KXsN7UeUJjjimx2uwd gCgNhr0i8C/xyCD5CiCKAMY3Bf5oDzx//w/fimscdcAZU2jv9sedx6+nYPPFIoWI/GK6QZ+EFGOR ErAjCnV3vPZ7XqlTIMbOLY7fLcvvmT7rXNWaGDexIY44N12TG2PDp7vqyl57dnCeuWwyNpnEURxk fTbDYeBnKRn4oejPYI4sH6WviBumEZ/GxX4X/x6EcURFZ7E071bjQGAxpcOAEOJuTiroDEea5Szv rVWLYfl7ZiQwSUToxrkux7OLixAWGz22+HIyWTRYcVfomOwvzusfjtVIGgLHf3MAAAAASUVORK5C YII= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) Cancel-Lock: sha1:R+HgoJkkuFVlkHvG8R48XaqhNYA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.1 (----) On 2011-03-29 12:41 +0800, Leo wrote: > +(defun abbrev-save-buffer () > + "Save all user-level abbrev definitions in current buffer. > +The saved abbrevs are written to the file specified by > +`abbrev-file-name'." > + (interactive) > + (and (derived-mode-p 'edit-abbrevs-mode) > + (edit-abbrevs-redefine)) > + (write-abbrev-file abbrev-file-name t)) > + > +(defun abbrev-save-to-file (file) > + "Save all user-level abbrev definitions in current buffer to FILE." > + (interactive > + (list (read-file-name "Save abbrevs to file: " > + (file-name-directory > + (expand-file-name abbrev-file-name)) > + abbrev-file-name))) > + (and (derived-mode-p 'edit-abbrevs-mode) > + (edit-abbrevs-redefine)) > + (write-abbrev-file file t)) Should define abbrev-save-buffer as: (defun abbrev-save-buffer () "Save all user-level abbrev definitions in current buffer. The saved abbrevs are written to the file specified by `abbrev-file-name'." (interactive) (abbrev-save-to-file abbrev-file-name)) From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 09:50:14 2011 Received: (at submit) by debbugs.gnu.org; 29 Mar 2011 13:50:14 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4ZJG-0007nU-DM for submit@debbugs.gnu.org; Tue, 29 Mar 2011 09:50:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4ZJE-0007nJ-M1 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 09:50:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4ZJ8-0001WE-4K for submit@debbugs.gnu.org; Tue, 29 Mar 2011 09:50:07 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:48672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4ZIv-0001P5-42 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 09:50:06 -0400 Received: from [140.186.70.92] (port=60899 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4ZIQ-0004oD-1G for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 09:49:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4ZIK-0001Nk-LV for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 09:49:17 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:52377 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4ZIK-0001NZ-Gj for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 09:49:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAIzikU1MCqRC/2dsb2JhbAClTHiIebwnhWoElhA X-IronPort-AV: E=Sophos;i="4.63,262,1299474000"; d="scan'208";a="98498903" Received: from 76-10-164-66.dsl.teksavvy.com (HELO pastel.home) ([76.10.164.66]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 29 Mar 2011 09:49:15 -0400 Received: by pastel.home (Postfix, from userid 20848) id 1B01358EBD; Tue, 29 Mar 2011 09:49:15 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Tue, 29 Mar 2011 09:49:15 -0400 In-Reply-To: (Leo's message of "Tue, 29 Mar 2011 13:16:23 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.1 (----) >> +(defun abbrev-save-buffer () >> + "Save all user-level abbrev definitions in current buffer. >> +The saved abbrevs are written to the file specified by >> +`abbrev-file-name'." >> + (interactive) >> + (and (derived-mode-p 'edit-abbrevs-mode) >> + (edit-abbrevs-redefine)) No need for the derived-mode-p check. But this reminds me: the name should include "edit" (e.g. abbrev-edit-save-buffer) to make it clear that it's about edit-abbrevs. >> +(defun abbrev-save-to-file (file) Same here. >> + "Save all user-level abbrev definitions in current buffer to FILE." >> + (interactive >> + (list (read-file-name "Save abbrevs to file: " >> + (file-name-directory >> + (expand-file-name abbrev-file-name)) >> + abbrev-file-name))) >> + (and (derived-mode-p 'edit-abbrevs-mode) >> + (edit-abbrevs-redefine)) >> + (write-abbrev-file file t)) > Should define abbrev-save-buffer as: > (defun abbrev-save-buffer () > "Save all user-level abbrev definitions in current buffer. > The saved abbrevs are written to the file specified by > `abbrev-file-name'." > (interactive) > (abbrev-save-to-file abbrev-file-name)) Yes, that sounds like a good idea. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 11:43:08 2011 Received: (at submit) by debbugs.gnu.org; 29 Mar 2011 15:43:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4b4V-00020P-OH for submit@debbugs.gnu.org; Tue, 29 Mar 2011 11:43:08 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4b4T-0001zv-3M for submit@debbugs.gnu.org; Tue, 29 Mar 2011 11:43:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4b4N-0007p2-74 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 11:43:00 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:58111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4b4N-0007oy-43 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 11:42:59 -0400 Received: from [140.186.70.92] (port=40529 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4b4L-0007RX-S8 for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 11:42:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4b4K-0007od-Ax for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 11:42:57 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:50940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4b4K-0007oZ-7y for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 11:42:56 -0400 Received: by iwg8 with SMTP id 8so399756iwg.0 for ; Tue, 29 Mar 2011 08:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=6vll5OMlhtMmMaeFQ7QdBcbcCT7BSBZRDTnuQbUDQQs=; b=dNIBkYJdyntc7hixKKBX9ZJhB2g3ukHUMJNnFh21CsRgMkTmxbixIVDehv31dCEwkn kldcyFwvGetYC9yAjTqOTH6jkKJnu43qf378eOQ6jwF4mxfysGDP8AA0Q+6v5vzcBXpI S8BJkk8aa+WtjJKMzaFVi0sgE8+Oz3p7P6QFw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=FyhRjR2q+3DoEvWY4PTQ9xCmh1H5D9c8j/+zW3TwtGNYhMkEZrE8WV9wxUhpCizfyX 2XQNobF72ROw7cLQfLlfq2WEJ9H9fhueK8GxxiO74Z7yKOnE/l8vqfQwlq1c1NnaOW3/ tSy2laTv2Yu4N4DzW8DZj7Baxq1YwUncINzuc= Received: by 10.42.74.194 with SMTP id x2mr9581785icj.113.1301413375015; Tue, 29 Mar 2011 08:42:55 -0700 (PDT) Received: from Victoria.local (th041102.ip.tsinghua.edu.cn [59.66.41.102]) by mx.google.com with ESMTPS id u9sm3729886ibe.36.2011.03.29.08.42.43 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Mar 2011 08:42:53 -0700 (PDT) From: Leo To: Stefan Monnier Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Tue, 29 Mar 2011 23:42:36 +0800 In-Reply-To: (Stefan Monnier's message of "Tue, 29 Mar 2011 09:49:15 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) Hopefully this patch is ready to commit. diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 0a3e1fd1..fbc4bdbd 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -73,7 +73,8 @@ (put 'abbrev-mode 'safe-local-variable 'booleanp) (defvar edit-abbrevs-map (let ((map (make-sparse-keymap))) - (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) + (define-key map "\C-x\C-s" 'abbrev-edit-save-buffer) + (define-key map "\C-x\C-w" 'abbrev-edit-save-to-file) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) map) "Keymap used in `edit-abbrevs'.") @@ -224,13 +225,15 @@ (defun quietly-read-abbrev-file (&optional file) ;(interactive "fRead abbrev file: ") (read-abbrev-file file t)) -(defun write-abbrev-file (&optional file) +(defun write-abbrev-file (&optional file verbose) "Write all user-level abbrev definitions to a file of Lisp code. This does not include system abbrevs; it includes only the abbrev tables listed in listed in `abbrev-table-name-list'. The file written can be loaded in another session to define the same abbrevs. The argument FILE is the file name to write. If omitted or nil, the file -specified in `abbrev-file-name' is used." +specified in `abbrev-file-name' is used. +If VERBOSE is non-nil, display a message indicating where abbrevs +have been saved." (interactive (list (read-file-name "Write abbrev file: " @@ -260,7 +263,25 @@ (defun write-abbrev-file (&optional file) 'emacs-mule))) (goto-char (point-min)) (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) - (write-region nil nil file nil 0)))) + (write-region nil nil file nil (and (not verbose) 0))))) + +(defun abbrev-edit-save-to-file (file) + "Save all user-level abbrev definitions in current buffer to FILE." + (interactive + (list (read-file-name "Save abbrevs to file: " + (file-name-directory + (expand-file-name abbrev-file-name)) + abbrev-file-name))) + (edit-abbrevs-redefine) + (write-abbrev-file file t)) + +(defun abbrev-edit-save-buffer () + "Save all user-level abbrev definitions in current buffer. +The saved abbrevs are written to the file specified by +`abbrev-file-name'." + (interactive) + (abbrev-edit-save-to-file abbrev-file-name)) + (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 16:54:55 2011 Received: (at submit) by debbugs.gnu.org; 29 Mar 2011 20:54:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4fwE-0001I8-Az for submit@debbugs.gnu.org; Tue, 29 Mar 2011 16:54:54 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4fwC-0001Hx-0e for submit@debbugs.gnu.org; Tue, 29 Mar 2011 16:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4fw5-0006v2-UG for submit@debbugs.gnu.org; Tue, 29 Mar 2011 16:54:46 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:43890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4fw5-0006uT-Di for submit@debbugs.gnu.org; Tue, 29 Mar 2011 16:54:45 -0400 Received: from [140.186.70.92] (port=46201 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4fvz-0001l4-3Y for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 16:54:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4fvr-0006sa-A2 for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 16:54:32 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:50769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4fvr-0006ri-29 for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2011 16:54:31 -0400 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id p2TKs7l3023584; Tue, 29 Mar 2011 16:54:07 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 1F345B4465; Tue, 29 Mar 2011 16:54:07 -0400 (EDT) From: Stefan Monnier To: Leo Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables Message-ID: References: Date: Tue, 29 Mar 2011 16:54:07 -0400 In-Reply-To: (Leo's message of "Tue, 29 Mar 2011 23:42:36 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3811=0 X-NAI-Spam-Version: 2.2.0.9286 : core <3811> : streams <614764> : uri <838184> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: bug-gnu-emacs@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) > Hopefully this patch is ready to commit. Looks good, thanks, Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 29 21:08:32 2011 Received: (at 5937-done) by debbugs.gnu.org; 30 Mar 2011 01:08:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4jtg-0006nF-46 for submit@debbugs.gnu.org; Tue, 29 Mar 2011 21:08:32 -0400 Received: from mail-iw0-f172.google.com ([209.85.214.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4jtd-0006n4-VR for 5937-done@debbugs.gnu.org; Tue, 29 Mar 2011 21:08:30 -0400 Received: by iwn39 with SMTP id 39so692411iwn.3 for <5937-done@debbugs.gnu.org>; Tue, 29 Mar 2011 18:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=/+rO+df0RhFqmXh8OUXa1ijAhhSzStRVEKMODhXy37k=; b=mRWBhClQyVAnz52Bb1TttdQm+eHWABGQS27ju1tWCHLwYEfl6Rf50ByZYmnFr6gZIA 5CAXKEAZBHch3EPOZaaTDftHxZattNioYqTHBRUbOTeJqSEO522pnps9Vnxb+oJvPJRK LecjPPUMvpdtCzX8Cax31mAtHLxtc3fqG8D4U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version:content-type; b=JKDc75MmOHCkijtzRRbTZhYMSD+HJl+tC1PZqGBKgkhgUBNF/0qquvLw/vrWxYN4Qn TLbGcP2WaCY7NwaCSgoPNgnNOe1jgAXkcGqxGJK3fQli5IIaewswJ7A2sQh0HhhamjpT UtDtBrMzz1ukWG4O17+1MLlVgWFb/llcT7nzI= Received: by 10.42.75.196 with SMTP id b4mr298201ick.372.1301447304206; Tue, 29 Mar 2011 18:08:24 -0700 (PDT) Received: from Victoria.local (th041109.ip.tsinghua.edu.cn [59.66.41.109]) by mx.google.com with ESMTPS id gx2sm3991073ibb.9.2011.03.29.18.08.21 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Mar 2011 18:08:23 -0700 (PDT) From: Leo To: 5937-done@debbugs.gnu.org Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables References: Date: Wed, 30 Mar 2011 09:08:18 +0800 In-Reply-To: (Stefan Monnier's message of "Tue, 29 Mar 2011 16:54:07 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: 5937-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) Version: 24.1 From unknown Mon Aug 18 11:29:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 27 Apr 2011 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator