unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#47454: plist-put should have a version which accepts multiple properties
@ 2021-03-28 17:34 scame via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-05-18 16:13 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: scame via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-03-28 17:34 UTC (permalink / raw)
  To: 47454

Modifying plists could be much easier if multiple properties
were also accepted.

E.g. (plist-put PLIST PROP VAL ... )

or (plist-put PLIST (PROP VAL ....) )


Others also find this problematic:

https://emacs.stackexchange.com/questions/39473/how-to-modify-multiple-keys-in-a-plist

and the suggessted solutions are clumsy:

  (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))
  (setq org-format-latex-options (plist-put org-format-latex-options :foreground 'auto))

or

  (setq org-format-latex-options
      (plist-put (plist-put org-format-latex-options
                            :scale 1.5)
                 :foreground 'auto))


Making plist-put smarter to accept multiple values or adding an
other function which accepts them (e.g. plist-put-multiple)
could make using plists much more convenient.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#47454: plist-put should have a version which accepts multiple properties
  2021-03-28 17:34 bug#47454: plist-put should have a version which accepts multiple properties scame via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-18 16:13 ` Lars Ingebrigtsen
  2021-06-14 21:53   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-18 16:13 UTC (permalink / raw)
  To: scame; +Cc: 47454

scame <laszlomail@protonmail.com> writes:

> Modifying plists could be much easier if multiple properties
> were also accepted.
>
> E.g. (plist-put PLIST PROP VAL ... )
>
> or (plist-put PLIST (PROP VAL ....) )
>
> Others also find this problematic:
>
> https://emacs.stackexchange.com/questions/39473/how-to-modify-multiple-keys-in-a-plist
>
> and the suggessted solutions are clumsy:
>
>   (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))
>   (setq org-format-latex-options (plist-put org-format-latex-options :foreground 'auto))

Well...  pretty much any key/value storage function works like this --
for instance, you can't put more than one key/value into a hash table
with puthash.  puthash does have the advantage that you don't have to
setq the variable, so it's somewhat less verbose.

(setf (seq-elt plist ...))

may help with that, though.

In any case, I don't think extending plist-put (or adding a new function
to take a list would be that useful, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#47454: plist-put should have a version which accepts multiple properties
  2021-05-18 16:13 ` Lars Ingebrigtsen
@ 2021-06-14 21:53   ` Juri Linkov
  2021-06-15 12:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2021-06-14 21:53 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 47454

> (setf (seq-elt plist ...))
>
> may help with that, though.

BTW, often after pulling from master and recompiling,
Emacs fails to start with such errors:

Debugger entered--Lisp error: (error "(setf seq-elt) is already defined as something else than a generic function")
  error("%s is already defined as something else than a generic function" \(setf\ seq-elt\))
  cl-generic-ensure-function(\(setf\ seq-elt\))
  cl-generic-define-method(\(setf\ seq-elt\) nil (store (sequence array) n) nil #f(compiled-function (store sequence n) #<bytecode -0x1d67862086490644>))
  byte-code(...)
  require(seq)
  byte-cod...)
  require(gnus-util)
  byte-code(...)
  require(nnheader)
  byte-code(...)
  require(gnus)

This requires bootstrap that fixes it.
But I wonder if maybe there is some deeply hidden problem with setf and seq-elt?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#47454: plist-put should have a version which accepts multiple properties
  2021-06-14 21:53   ` Juri Linkov
@ 2021-06-15 12:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-06-16 16:55       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-06-15 12:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 47454

Juri Linkov [2021-06-15 00:53:54] wrote:

>> (setf (seq-elt plist ...))
>>
>> may help with that, though.
>
> BTW, often after pulling from master and recompiling,
> Emacs fails to start with such errors:
>
> Debugger entered--Lisp error: (error "(setf seq-elt) is already defined as
> something else than a generic function")
>   error("%s is already defined as something else than a generic function" \(setf\ seq-elt\))
>   cl-generic-ensure-function(\(setf\ seq-elt\))
>   cl-generic-define-method(\(setf\ seq-elt\) nil (store (sequence array) n)
> nil #f(compiled-function (store sequence n)

Hmm....

When you see that, could you show us the value of:

    (symbol-function '\(setf\ seq-elt\))


-- Stefan






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#47454: plist-put should have a version which accepts multiple properties
  2021-06-15 12:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-06-16 16:55       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-06-16 16:55 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 47454

forcemerge 47454 49053
close 47454 49053
thanks

Stefan Monnier [2021-06-15 08:48:25] wrote:

> Juri Linkov [2021-06-15 00:53:54] wrote:
>
>>> (setf (seq-elt plist ...))
>>>
>>> may help with that, though.
>>
>> BTW, often after pulling from master and recompiling,
>> Emacs fails to start with such errors:
>>
>> Debugger entered--Lisp error: (error "(setf seq-elt) is already defined as
>> something else than a generic function")
>>   error("%s is already defined as something else than a generic function" \(setf\ seq-elt\))
>>   cl-generic-ensure-function(\(setf\ seq-elt\))
>>   cl-generic-define-method(\(setf\ seq-elt\) nil (store (sequence array) n)
>> nil #f(compiled-function (store sequence n)
>
> Hmm....
>
> When you see that, could you show us the value of:
>
>     (symbol-function '\(setf\ seq-elt\))

I installed the patch below which apparently fixes this problem


        Stefan


diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 31aa0cb4f9..544704be38 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -568,17 +568,17 @@ cl-generic-define-method
               (cons method mt)
             ;; Keep the ordering; important for methods with :extra qualifiers.
             (mapcar (lambda (x) (if (eq x (car me)) method x)) mt)))
-    (let ((sym (cl--generic-name generic))) ; Actual name (for aliases).
+    (let ((sym (cl--generic-name generic)) ; Actual name (for aliases).
+          ;; FIXME: Try to avoid re-constructing a new function if the old one
+          ;; is still valid (e.g. still empty method cache)?
+          (gfun (cl--generic-make-function generic)))
       (unless (symbol-function sym)
         (defalias sym 'dummy))   ;Record definition into load-history.
       (cl-pushnew `(cl-defmethod . ,(cl--generic-load-hist-format
                                      (cl--generic-name generic)
                                      qualifiers specializers))
                   current-load-list :test #'equal)
-      ;; FIXME: Try to avoid re-constructing a new function if the old one
-      ;; is still valid (e.g. still empty method cache)?
-      (let ((gfun (cl--generic-make-function generic))
-            ;; Prevent `defalias' from recording this as the definition site of
+      (let (;; Prevent `defalias' from recording this as the definition site of
             ;; the generic function.
             current-load-list
             ;; BEWARE!  Don't purify this function definition, since that leads






^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-16 16:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-28 17:34 bug#47454: plist-put should have a version which accepts multiple properties scame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-18 16:13 ` Lars Ingebrigtsen
2021-06-14 21:53   ` Juri Linkov
2021-06-15 12:48     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-16 16:55       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).