[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29923: [PATCH] Skip writing empty abbrev tables

From: Allen Li
Subject: bug#29923: [PATCH] Skip writing empty abbrev tables
Date: Fri, 14 Sep 2018 18:22:07 -0700

On Sun, Sep 9, 2018 at 1:43 PM Noam Postavsky <address@hidden> wrote:
> Allen Li <address@hidden> writes:
> > Subject: [PATCH] Skip writing empty abbrev tables
> >
> > Fixes bug#29923
> >
> > * lisp/abbrev.el (write-abbrev-file): Pass SKIPEMPTY to
> > insert-abbrev-table-description.
> > (insert-abbrev-table-description): Add SKIPEMPTY optional
> > parameter. Skip inserting empty tables if SKIPEMPTY is non-nil.
> >  (eval-when-compile (require 'cl-lib))
> >  (require 'obarray)
> > +(require 'seq)
> You didn't end up using seq, as far as I can tell.

Thanks, removed.

> > -(defun insert-abbrev-table-description (name &optional readable)
> > +(defun insert-abbrev-table-description (name &optional readable skipempty)
> >    "Insert before point a full description of abbrev table named NAME.
> >  NAME is a symbol whose value is an abbrev table.
> >  If optional 2nd arg READABLE is non-nil, a human-readable description
> >  is inserted.  Otherwise the description is an expression,
> >  a call to `define-abbrev-table', which would
> >  define the abbrev table NAME exactly as it is currently defined.
> > +If optional arg SKIPEMPTY is non-nil, skip insertion if table is empty.
> >
> >  Abbrevs marked as \"system abbrevs\" are omitted."
> > -    (mapatoms (lambda (sym) (if (symbol-value sym) (push sym symbols))) 
> > table)
> > +    (mapatoms (lambda (sym)
> > +                (if (and (symbol-value sym) (not (abbrev-get sym :system)))
>                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Looks like the second check you added implements the "Abbrevs marked as
> \"system abbrevs\" are omitted" part.  I guess that actually fixes an
> additional bug?  Worth mentioning in the commit message, I think.

The system abbrev omitting worked (if readable is nil); it's
implemented in abbrev--write.
However, that doesn't allow us to skip writing a table if it only
contains system abbrevs;
we'll still see a table with abbrevs, write the opening of the
define-abbrev-table form,
and then realize in abbrev-write that all of the abbrevs are system abbrevs.

I noticed a bug in my patch where it would skip system abbrevs if
readable was non-nil
when it did not skip system abbrevs previously.  I fixed this and also
fixed the docstring
to match what I believe is the intended behavior.

Attachment: 0001-Skip-writing-empty-abbrev-tables.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]