emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Fix regex for determining image width from attribute
Date: Tue, 23 Nov 2021 23:44:50 +0700	[thread overview]
Message-ID: <snj5q8$dai$1@ciao.gmane.io> (raw)
In-Reply-To: <87k0gzpb5s.fsf@gmail.com>

On 23/11/2021 14:46, Matt Huszagh wrote:
> Here are two patches that prioritize attr_org over other attr_
> keywords. I believe this is what you had in mind Timothy. But let me
> know if not.

> diff --git a/lisp/org.el b/lisp/org.el
> index 308bb7d51..bf5d08e09 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -16853,13 +16853,20 @@ buffer boundaries with possible narrowing."
>     ((listp org-image-actual-width)
>      (let* ((case-fold-search t)
>             (par (org-element-lineage link '(paragraph)))
> -           (attr-re "^[ \t]*#\\+attr_.*?: +.*?:width +\\(\\S-+\\)")
> +           (attr-re (lambda (backend)
> +                      (concat "^[ \t]*#\\+attr_"
> +                              backend
> +                              ": +.*?:width +\\(\\S-+\\)")))
>             (par-end (org-element-property :post-affiliated par))
> -           ;; Try to find an attribute providing a :width.
> +           ;; If an attr_org provides a :width, use that. Otherwise,
> +           ;; use the first attribute that provides it, if any.
>             (attr-width
>              (when (and par (org-with-point-at
>                                 (org-element-property :begin par)
> -                             (re-search-forward attr-re par-end t)))
> +                             (or (re-search-forward (funcall attr-re "org")
> +                                                    par-end t)
> +                                 (re-search-forward (funcall attr-re ".*?")
> +                                                    par-end t))))

I may be wrong, but it seems both the old and the new regexps match

     #+attr_html : :width 50%

that is not a keyword due to a space before ":". The dot in the regexp 
is too permissive.

> The second patch (intended to be applied after the first) improves the
> documentation. It describes behavior that wasn't previously documented
> and removes redundant documentation between org-image-actual-width and
> org-display-inline-image--width (now only in
> org-image-actual-width). Please double check I got everything correct,
> as I haven't used all this behavior myself.

> +that is not found, use the first #+ATTR_.*:width specification.

Despite ".*" includes ": " before ":width", I would prefer explicit 
space before ":width".




  reply	other threads:[~2021-11-23 16:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-21 19:08 Matt Huszagh
2021-11-21 19:20 ` Timothy
2021-11-21 19:51   ` Matt Huszagh
2021-11-22  8:29     ` Timothy
2021-11-22 16:11       ` Matt Huszagh
2021-11-22 17:54         ` Timothy
2021-11-22 20:53           ` Matt Huszagh
2021-11-23  4:59             ` Kyle Meyer
2021-11-23  5:14             ` Timothy
2021-11-23  5:38               ` Matt Huszagh
2021-11-23  5:39                 ` Timothy
2021-11-23  7:46                   ` Matt Huszagh
2021-11-23 16:44                     ` Max Nikulin [this message]
2021-11-24  1:57                       ` Matt Huszagh
2021-11-24 14:48                         ` Max Nikulin
2021-11-24 15:59                           ` Matt Huszagh
2021-11-24 17:00                             ` Max Nikulin
2021-11-25 16:43                               ` Max Nikulin
2021-11-29  0:23                                 ` Matt Huszagh
2021-11-29  5:13                                   ` Timothy
2021-12-01  3:24                                     ` Matt Huszagh
2021-12-01  4:54                                       ` Timothy
2021-12-03  2:06                                         ` Matt Huszagh
2021-11-29 12:15                                   ` Max Nikulin
2021-11-22 14:30     ` Max Nikulin

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='snj5q8$dai$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH] Fix regex for determining image width from attribute' \
    /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

Code repositories for project(s) associated with this 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).