emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] org-bibtex-yank: Allow to populate existing item


From: Ihor Radchenko
Subject: Re: [PATCH] org-bibtex-yank: Allow to populate existing item
Date: Sun, 18 Feb 2024 14:29:09 +0000

Martin Kampas <martin.kampas@ubedi.net> writes:

> The attached patch allows to use org-bibtex-yank to 
> populate an existing item instead of creating a new one, 
> aligning its behavior with org-bibtex-create.

Thanks!

> Subject: [PATCH] org-bibtex-yank: Allow to populate existing item
>
> Align with org-bibtex-create.

Please quote like `org-bibtex-create'. Here and in the rest of the
commit message. See https://orgmode.org/worg/org-contribute.html#orgfabdc17

> * lisp/ol-bibtex.el (org-bibtex-write): New optional argument nonew,
>   similar to the existing nonew argument of org-bibtex-create
> * lisp/ol-bibtex.el (org-bibtex-yank): New optional argument nonew,
>   similar to the existing nonew argument of org-bibtex-create

When adding new arguments, we need to announce the change in
etc/ORG_NEWS file. Also, in `org-bibtex-yank', you did not only add an
optional argument, but also modified its behavior with prefix argument.
Changes in prefix arguments should also be announced - they directly
affect all the users.

> -(defun org-bibtex-write (&optional noindent)
> +(defun org-bibtex-write (&optional noindent nonew)
>    "Insert a heading built from the first element of `org-bibtex-entries'.
>  When optional argument NOINDENT is non-nil, do not indent the properties
> -drawer."
> +drawer. If NONEW is t, add data to the headline of the entry at point."

In the code, you do not check for t, but for non-nil. So, please say
"non-nil" in the docstring as well.

Also, I'd prefer a more descriptive name, like update-heading. nonew is
ambiguous - it can be interpreted in several ways.

> -(defun org-bibtex-yank ()
> -  "If kill ring holds a bibtex entry yank it as an Org headline."
> -  (interactive)
> -  (let (entry)
> +(defun org-bibtex-yank (&optional nonew)

> +  "If kill ring holds a bibtex entry yank it as an Org headline.
> +If nonew is t, add data to the headline of the entry at point."

Same here. And please upcase NONEW to indicate that it is a function argument.
Also, document that NONEW is interpreted as interactive prefix argument:

   When called with non-nil prefix argument NONEW, add data to the headline
   of the entry at point.

> +  (interactive "P")
> +  (let (entry
> +        (noindent nonew))

Why do you bind noindent here?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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