bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#68818: [PATCH] lisp/emacs-lisp/inline.el: Autoload public macros


From: Stefan Monnier
Subject: bug#68818: [PATCH] lisp/emacs-lisp/inline.el: Autoload public macros
Date: Tue, 30 Jan 2024 09:30:36 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>> This patch solves annoying problem with `define-inline' forms not being
>> indented correctly unless inline.el is explicitly loaded.
>> 
>> For illustration, try to open the following foo.el file:
>> 
>> (define-inline org-element-type-p (node types)
>>   "Return non-nil when NODE type is one of TYPES.
>> TYPES can be a type symbol or a list of symbols."
>>   (if (inline-const-p types)
>>       (if (listp (inline-const-val types))
>>           (inline-quote (memq (org-element-type ,node t) ,types))
>>         (inline-quote (eq (org-element-type ,node t) ,types)))
>>     (inline-letevals (node types)
>>       (inline-quote
>>        (if (listp ,types)
>>            (memq (org-element-type ,node t) ,types)
>>          (eq (org-element-type ,node t) ,types))))))

[ Side note: IIRC the above can be simplified as:

    (define-inline org-element-type-p (node types)
      "Return non-nil when NODE type is one of TYPES.
    TYPES can be a type symbol or a list of symbols."
      (inline-letevals (node types)
        (if (listp (inline-const-val types))
            (inline-quote (memq (org-element-type ,node t) ,types))
          (inline-quote (eq (org-element-type ,node t) ,types)))))

]

>> with emacs -Q, indenting the file will yield different results with and
>> without executing (require 'inline).
>> With the patch, indentation becomes consistent.
> Hmm, I wonder whether there's a less heavy-handed approach to this.

Agreed.  Also, I think this problem is not specific to `define-inline`.
Maybe the indentation code should try and (auto)load the macros
it encounters.


        Stefan






reply via email to

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