From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#5937: 23.1.95; why saving empty abbrev tables Date: Fri, 16 Apr 2010 11:36:21 +0100 Organization: University of Cambridge Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1271415560 20080 80.91.229.12 (16 Apr 2010 10:59:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Apr 2010 10:59:20 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 16 12:59:17 2010 connect(): No such file or directory Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O2jGV-0006fC-Rs for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Apr 2010 12:59:16 +0200 Original-Received: from localhost ([127.0.0.1]:44550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2jGU-0003TK-TC for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Apr 2010 06:59:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2jGM-0003S3-Br for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:59:06 -0400 Original-Received: from [140.186.70.92] (port=55998 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2jGK-0003QS-Gy for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:59:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2jGH-0003SE-RN for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:59:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36666) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2jGH-0003S9-MC for bug-gnu-emacs@gnu.org; Fri, 16 Apr 2010 06:59:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O2iuz-0005yP-Ps; Fri, 16 Apr 2010 06:37:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 16 Apr 2010 10:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5937 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.127141420622954 (code B ref -1); Fri, 16 Apr 2010 10:37:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 16 Apr 2010 10:36:46 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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/ connect(): No such file or directory Original-Lines: 108 Original-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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 16 Apr 2010 06:37:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36268 Archived-At: --=-=-= 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 --=-=-=--