emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Feraidoon Mehri <feraidoonmehri@gmail.com>, Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ox.el: Refactor variable org-html--id-attr-prefix, ox-html.el: Add support for the ID property to org-html--reference
Date: Tue, 25 Oct 2022 07:18:18 +0000	[thread overview]
Message-ID: <87ilk8tlqd.fsf@localhost> (raw)
In-Reply-To: <CABKKTciL=YDdyxvND6S2Vxp4_4=uayKEN793VcfhR1P2njzS-Q@mail.gmail.com>

Feraidoon Mehri <feraidoonmehri@gmail.com> writes:

> I have already signed the copyright assignment. (Though I used my
> other email rudiwillalwaysloveyou@gmail.com when signing it.)

Bastien, could you kindly check the FSF records?

> I have manually tested the changes with a custom value for
> `org-html--id-attr-prefix', and everything works.
>
> I did not change the behavior of `org-html-prefer-user-labels'; the ID
> property will not be used if `org-html-prefer-user-labels' is nil. IMO
> this behavior should be changed, and it should be always used, just
> like CUSTOM_ID.

Thanks for the patch!
See my comments below.

> * org/ox.el (org-html--id-attr-prefix): Refactor hardcoded "ID-" as a
> new private variable.

org-html-* variable do not belong to the general ox.el library.  It
should only be added to ox-html.el.

> -	 (user-label
> -	  (org-element-property
> -	   (pcase type
> -	     ((or `headline `inlinetask) :CUSTOM_ID)
> -	     ((or `radio-target `target) :value)
> -	     (_ :name))
> -	   datum)))
> +         (custom-id-p nil)
> +         (user-label
> +          (or
> +           (org-element-property
> +            (pcase type
> +              ((or `headline `inlinetask)
> +               (progn
> +                 (setq custom-id-p t)
> +                 :CUSTOM_ID))
> +              ((or `radio-target `target) :value)
> +              (_ :name))
> +            datum)
> +           (if-let
> +               ((id-property (org-element-property
> +                              :ID
> +                              datum)))
> +               (progn
> +                 (setq custom-id-p nil)
> +                 (concat org-html--id-attr-prefix id-property))))))

This is a bit awkward to read.
Can you instead let-bind custom-id as a separate variable and leave :ID
to user-label? Then, you will not need to juggle setq custom-id-p and
the code will become more readable.

> diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
> index 7f2e8ba47f..d2c14237ac 100644
> --- a/lisp/org/ox-odt.el
> +++ b/lisp/org/ox-odt.el
> @@ -1802,7 +1802,7 @@ holding contextual information."
>  	   ;; Extra targets.
>  	   (extra-targets
>  	    (let ((id (org-element-property :ID headline)))
> -	      (if id (org-odt--target "" (concat "ID-" id)) "")))
> +	      (if id (org-odt--target "" (concat org-html--id-attr-prefix id)) "")))

It is surprising that org-html-* variable has anything to do with ODT
export. Please define a separate constant in ox-odt.

-- 
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	other threads:[~2022-10-25  8:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-22 11:17 [PATCH] ox.el: Refactor variable org-html--id-attr-prefix, ox-html.el: Add support for the ID property to org-html--reference Feraidoon Mehri
2022-10-25  7:18 ` Ihor Radchenko [this message]
2022-10-26 15:44   ` Bastien Guerry
2022-12-02  6:18   ` Ihor Radchenko
2023-04-05  9:26     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilk8tlqd.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=feraidoonmehri@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).