Re: [PATCH] Justify/align image previews in org-mode

2023-12-18 Thread Karthik Chikmagalur
I've incorporated the following suggestions:

- Order of precedence:
  + #+attr_org overrides #+attr_html and #+attr_latex
  + `:center t' overrides `:align ...'

- Update doc/org-manual.org under the images section.

- Add a checker for `:align nil' to org-lint.  `:align nil' is not
  supported.

- Unspecified behaviors:
  + The behavior of `:center nil` is undefined
  + #+attr_html vs #+attr_latex

- Include a commit message in the patch.  The included patch is based on
  the main branch.

Karthik
>From eb1b287c009c2f7eb83e7e31d64980ba79f44527 Mon Sep 17 00:00:00 2001
From: Karthik Chikmagalur 
Date: Mon, 18 Dec 2023 12:56:33 -0800
Subject: [PATCH] org: Add image alignment

* lisp/org.el (org-image--align, org-image-align,
org-toggle-inline-images): Add the ability to left-align, center
or right-align inline image previews in the Emacs window. This is
controlled globally using the new user option `org-image-align'.
Alignment can be specified per image using the `#+ATTR.*'
affiliated keywords.  The function `org-image--align' determines
the kind of alignment for its argument link.

* lisp/org-lint.el (org-lint-invalid-image-alignment): Add an
org-lint checker for the pattern ":align nil" in `#+ATTR.*'
keywords.  This alignment specification is not supported.

* doc/org-manual.org: Document the new feature under the Images
section.
---
 doc/org-manual.org | 34 +
 lisp/org-lint.el   | 17 +
 lisp/org.el| 91 +++---
 3 files changed, 137 insertions(+), 5 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 5217e647d..0df730f2b 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11501,6 +11501,40 @@ command:
 and fall back on the original width if none is found.
 
 
+  #+vindex: org-image-align
+  Org mode can left-align, center or right-align the display of inline
+  images.  This setting is controlled (globally) by ~org-image-align~.
+  Only standalone links, /i.e/ links with no surrounding text in their
+  paragraphs (except whitespace) are affected.  Its value can be the
+  following:
+  - (default) nil, insert the image where the link appears in the
+buffer.
+  - The symbol ~left~, which is the same as nil.
+  - The symbol ~center~, which will preview standalone links centered
+in the Emacs window.
+  - The symbol ~right~, which will preview standalone links
+right-aligned in the Emacs window.
+
+  Inline image alignment can be specified for each link using the
+  =#+ATTR.*= keyword if it matches an alignment specification like:
+  #+begin_example
+  ,#+ATTR_HTML: :align center
+  #+end_example
+  Supported values for =:align= are =left=, =center= and =right=.
+  Inline image display can also be centered using =:center=, as in
+  #+begin_example
+  ,#+ATTR_HTML: :center t
+  #+end_example
+  Org will use the alignment specification from any =#+ATTR.*=
+  keyword, such as =#+ATTR_HTML= or =#+ATTR_LATEX=, but =#+ATTR_ORG=
+  (if present) will override the others.  For instance, this link
+  #+begin_example
+  ,#+ATTR_HTML: :align right
+  ,#+ATTR_ORG: :align center
+  [[/path/to/image/file.png]]
+  #+end_example
+  will be displayed centered.
+
 #+vindex: org-cycle-inline-images-display
 Inline images can also be displayed when cycling the folding state.
 When custom option ~org-cycle-inline-images-display~ is set, the
diff --git a/lisp/org-lint.el b/lisp/org-lint.el
index 0e2967b6c..84bca9f48 100644
--- a/lisp/org-lint.el
+++ b/lisp/org-lint.el
@@ -964,6 +964,18 @@ Use \"export %s\" instead"
 		reports
 reports))
 
+(defun org-lint-invalid-image-alignment (ast)
+  (org-element-map ast 'paragraph
+(lambda (p)
+  (let ((bad-align-re ":align[[:space:]]+nil")
+(keyword-string (mapconcat
+ (lambda (attr)
+   (or (car-safe (org-element-property attr p)) ""))
+ '(:attr_org :attr_latex :attr_html) " ")))
+(when (string-match-p bad-align-re keyword-string)
+(list (org-element-begin p)
+  "nil is not a supported value for keyword attribute \":align\""))
+
 (defun org-lint-extraneous-element-in-footnote-section (ast)
   (org-element-map ast 'headline
 (lambda (h)
@@ -1390,6 +1402,11 @@ Use \"export %s\" instead"
   #'org-lint-invalid-keyword-syntax
   :trust 'low)
 
+(org-lint-add-checker 'invalid-image-alignment
+  "Report unsupported align attribute for keyword"
+  #'org-lint-invalid-image-alignment
+  :trust 'low)
+
 (org-lint-add-checker 'invalid-block
   "Report invalid blocks"
   #'org-lint-invalid-block
diff --git a/lisp/org.el b/lisp/org.el
index 59fe3d2d3..8a8bd977d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16175,6 +16175,26 @@ cache   Display remote images, and open them in separate buffers
 	  (const :tag "Display and silently update remote images" cache))
   :safe #'symbolp)
 
+(defcustom org-image-align nil
+  "How to align 

Re: [PATCH] Justify/align image previews in org-mode

2023-12-18 Thread Karthik Chikmagalur
> I can only suggest something like
> 
> (equal (org-element-begin link)
> (save-excursion
>   (goto-char (org-element-contents-begin paragraph))
>   (skip-chars-forward "\t ")
>   (point)))
> 
> (equal (org-element-end link)
> (save-excursion
>   (goto-char (org-element-contents-end paragraph))
>   (skip-chars-backward "\t ")
>   (point)))

This should be fine, it's what we do in many places in org-latex-preview.

> > - Does org-element provide a property that can help here? I tried
> > :pre-blank but it was nil, I'm not sure what it does.
> 
> :pre-blank is for blank lines before contents. Leading whitespace is
> considered a part of the paragraph:
> (paragraph (...) "  " (link ...) "\n")

Good to know.

I've attached the latest version of the patch.

- 'justify is no longer an option

- 'left is now supported as a value of `org-image-align', although of
  course this is a noop.

- Leading and trailing whitespace are handled correctly.  The image
  overlay swallows up any trailing whitespace if there is nothing else
  on that line.

- Right alignment will still fail in some odd circumstances, such as if
  there's an overlay with a display property to the right of the image.
  To see an example of this, turn on whitespace-mode and try to
  right-align a standalone image.  I don't think it's worth handling
  cases like these at least for now.

Karthik
diff --git a/lisp/org.el b/lisp/org.el
index 30a4e7aef..1efd2f31b 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15673,6 +15673,26 @@ cache   Display remote images, and open them in separate buffers
 	  (const :tag "Display and silently update remote images" cache))
   :safe #'symbolp)
 
+(defcustom org-image-align nil
+  "How to align images previewed using `org-display-inline-images'.
+
+Only stand-alone image links are affected by this setting.  These
+are links without surrounding text.
+
+Possible values of this option are:
+
+nil  Insert image at specified position.
+left Insert image at specified position (same as nil).
+center   Center image previews.
+rightRight-align image previews."
+  :group 'org-appearance
+  :package-version '(Org . "9.7")
+  :type '(choice
+  (const :tag "Left align (or don\\='t align) image previews" nil)
+	  (const :tag "Center image previews" center)
+	  (const :tag "Right align image previews" right))
+  :safe #'symbolp)
+
 (defun org--create-inline-image (file width)
   "Create image located at FILE, or return nil.
 WIDTH is the width of the image.  The image may not be created
@@ -15807,7 +15827,8 @@ buffer boundaries with possible narrowing."
   (when file (setq file (substitute-in-file-name file)))
 		  (when (and file (file-exists-p file))
 		(let ((width (org-display-inline-image--width link))
-			  (old (get-char-property-and-overlay
+			  (align (org-image--align link))
+  (old (get-char-property-and-overlay
 (org-element-begin link)
 'org-image-overlay)))
 		  (if (and (car-safe old) refresh)
@@ -15819,7 +15840,7 @@ buffer boundaries with possible narrowing."
    (progn
 	 (goto-char
 	  (org-element-end link))
-	 (skip-chars-backward " \t")
+	 (unless (eolp) (skip-chars-backward " \t"))
 	 (point)
   ;; FIXME: See bug#59902.  We cannot rely
   ;; on Emacs to update image if the file
@@ -15833,6 +15854,15 @@ buffer boundaries with possible narrowing."
 			   (list 'org-display-inline-remove-overlay))
 			  (when (boundp 'image-map)
 (overlay-put ov 'keymap image-map))
+  (when align
+(overlay-put
+ ov 'before-string
+ (propertize
+  " " 'face 'default
+  'display
+  (pcase align
+('center `(space :align-to (- center (0.5 . ,image
+('right  `(space :align-to (- right ,image)))
 			  (push ov org-inline-image-overlays
 
 (defvar visual-fill-column-width) ; Silence compiler warning
@@ -15894,6 +15924,43 @@ buffer boundaries with possible narrowing."
   org-image-actual-width)
  (t nil
 
+(defun org-image--align (link)
+  "Determine the alignment of the image link.
+
+This is controlled globally by the option `org-image-align', and
+per image by the value of `:align' in the affiliated keyword
+`#+attr_org'.
+
+The result is either nil or one of the symbols left, center or
+right.
+
+center will cause the image preview to be centered, right will
+cause it to be right-aligned.  A value of left or nil
+implies no special alignment."
+  (let ((par (org-element-lineage link 'paragraph)))
+;; Only apply when image is not surrounded by paragraph text:
+(when (and (= (org-element-begin link)
+  

Re: [BUG] Tab width in Org files must be 8, not 4 [9.7-pre (release_9.6.13-995-g1d7297 @ /Users/michael/.config/emacs/straight/build/org/)]

2023-12-18 Thread Michael Dixon
Oh… that would do it. Thank you for your help!

> On Dec 18, 2023, at 12:10, Ihor Radchenko  wrote:
> 
> Michael Dixon mailto:dixiu...@gmail.com>> writes:
> 
>> After a recent update, when I am editing a bulleted list (with an indent
>> of 2 spaces, like you can see in the Org manual), I get the following
>> error when I press , M-, etc.:
>> 
>> Tab width in Org files must be 8, not 4
>> 
>> This happens within any heading in which the bulleted list exists. If I
>> create a new heading, I can type text and paragraphs there with no
>> issue.
>> 
>> I just noticed this today, though I don't often use plain lists, so not
>> sure if it has been happening for longer.
> 
> This is because you have non-standard tab-width setting.
> See https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n36
> 
> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 



Re: [BUG] cannot export org-file: Warning (org-element-cache): org-element--cache: Got empty parent while parsing [9.6.12 (N/A @ /gnu/store/h6351wyaf8gahx46y71vd1200wr5l9gv-emacs-org-9.6.12/share/emac

2023-12-18 Thread Dr. Arne Babenhauserheide

Ihor Radchenko  writes:

> "Dr. Arne Babenhauserheide"  writes:
>
>> M-x org-toggle-debug-on-quit
>>
>>
>> Debugger entered--Lisp error: (quit)
>>   org-element--parse-to(13994)
>>   org-element-at-point()
>>   org--collect-keywords-1(("SETUPFILE" "BIND") nil nil 
>> ("/home/arne/Schreibtisch/arnebab-org/politik/geschl...") nil)
>>   org-collect-keywords(("BIND"))
>>   org-export--list-bound-variables()
>
> I am confused. Does it mean that you can reproduce the error manually,
> not from Makefile?

I can abort the publishing process in the Emacs started from the
Makefile (graphical Emacs, not in batch mode) and then export again from
the org-file, and then I see this error.

I cannot reproduce it from my regular Emacs session.

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: Citations bug with basic processor, plain bibliographies, LaTeX

2023-12-18 Thread William Denton

On 18 December 2023, Ihor Radchenko wrote:


Sigh... Fixed, on main. (I hope)
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=41726d408


Fixed!  Thanks.


Bill

--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada
CO₂: 422.67 ppm (Mauna Loa Observatory, 2023-12-17)

Re: Citations bug with basic processor, plain bibliographies, LaTeX

2023-12-18 Thread Ihor Radchenko
William Denton  writes:

> Ihor, you patched this, but I rebuilt Org and tried again and it fails with a 
> *Messages* showing a slightly different error:
>
> org-cite-basic--shorten-names: Wrong type argument: stringp, (raw nil #("van 
> Dongen, M.R.C." 0 18 (:parent #0)))
>
> Soon all of these bugs will be squashed!

Sigh... Fixed, on main. (I hope)
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=41726d408

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] Tab width in Org files must be 8, not 4 [9.7-pre (release_9.6.13-995-g1d7297 @ /Users/michael/.config/emacs/straight/build/org/)]

2023-12-18 Thread Ihor Radchenko
Michael Dixon  writes:

> After a recent update, when I am editing a bulleted list (with an indent
> of 2 spaces, like you can see in the Org manual), I get the following
> error when I press , M-, etc.:
>
> Tab width in Org files must be 8, not 4
>
> This happens within any heading in which the bulleted list exists. If I
> create a new heading, I can type text and paragraphs there with no
> issue.
>
> I just noticed this today, though I don't often use plain lists, so not
> sure if it has been happening for longer.

This is because you have non-standard tab-width setting.
See https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n36

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Justify/align image previews in org-mode

2023-12-18 Thread Ihor Radchenko
Karthik Chikmagalur  writes:

>> This will not work when the image paragraph is indented:
>
> * This is test
>   #+attr_org: :align center
>   [[file:~/Downloads/wallpaper.png]]
>
> - Is there a better way to address this than checking if there is only
> whitespace behind the link until the start of the paragraph?

I can only suggest something like

(equal (org-element-begin link)
(save-excursion
  (goto-char (org-element-contents-begin paragraph))
  (skip-chars-forward "\t ")
  (point)))

(equal (org-element-end link)
(save-excursion
  (goto-char (org-element-contents-end paragraph))
  (skip-chars-backward "\t ")
  (point)))

> - Does org-element provide a property that can help here? I tried
> :pre-blank but it was nil, I'm not sure what it does.

:pre-blank is for blank lines before contents. Leading whitespace is
considered a part of the paragraph:
(paragraph (...) "  " (link ...) "\n")

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Justify/align image previews in org-mode

2023-12-18 Thread Karthik Chikmagalur
> It would make sense to allow 'left value as well (same as nil).

Done.

> I do not think that we need to consider 'justify value at this point.
> Maybe in future, when (or if) we add proper justification support to
> text. But not now.

Removed support for 'justify.

> This will not work when the image paragraph is indented:

* This is test
  #+attr_org: :align center
  [[file:~/Downloads/wallpaper.png]]

- Is there a better way to address this than checking if there is only
whitespace behind the link until the start of the paragraph?
- Does org-element provide a property that can help here? I tried
:pre-blank but it was nil, I'm not sure what it does.

Karthik



Re: Citations bug with basic processor, plain bibliographies, LaTeX

2023-12-18 Thread William Denton
Ihor, you patched this, but I rebuilt Org and tried again and it fails with a 
*Messages* showing a slightly different error:


org-cite-basic--shorten-names: Wrong type argument: stringp, (raw nil #("van 
Dongen, M.R.C." 0 18 (:parent #0)))


Soon all of these bugs will be squashed!

Thanks,

Bill

On 15 December 2023, William Denton wrote:

I've found a bug on main that I think is related to the recent patches about 
raw string objects.


Try this as Basic.bib:

@book{friends,
 title = {{{LaTeX}} and Friends},
 author = {van Dongen, M.R.C.},
 date = {2012},
 location = {Berlin},
 publisher = {Springer},
 doi = {10.1007/978-3-642-23816-1},
 isbn = {9783642238161}
}

And then this as basic.org:

# --

#+bibliography: Basic.bib
#+cite_export: basic plain numeric
[cite:@friends]
#+print_bibliography:

# --

Exporting to text, HTML or ODT works, but trying with LaTeX gives this error:

mapconcat: Wrong type argument: stringp, (raw nil #("van Dongen, M.R.C." 0 18 
(:parent #0)))



--
William Denton
https://www.miskatonic.org/
Librarian, artist and licensed private investigator.
Toronto, Canada
CO₂: 422.67 ppm (Mauna Loa Observatory, 2023-12-17)

[BUG] Tab width in Org files must be 8, not 4 [9.7-pre (release_9.6.13-995-g1d7297 @ /Users/michael/.config/emacs/straight/build/org/)]

2023-12-18 Thread Michael Dixon
After a recent update, when I am editing a bulleted list (with an indent
of 2 spaces, like you can see in the Org manual), I get the following
error when I press , M-, etc.:

Tab width in Org files must be 8, not 4

This happens within any heading in which the bulleted list exists. If I
create a new heading, I can type text and paragraphs there with no
issue.

I just noticed this today, though I don't often use plain lists, so not
sure if it has been happening for longer.

Emacs  : GNU Emacs 29.1 (build 1, aarch64-apple-darwin22.5.0, Carbon Version 
169 AppKit 2299.6)
of 2023-08-12
Package: Org mode version 9.7-pre (release_9.6.13-995-g1d7297 @ 
/Users/michael/.config/emacs/straight/build/org/)



Re: [BUG] cannot export org-file: Warning (org-element-cache): org-element--cache: Got empty parent while parsing [9.6.12 (N/A @ /gnu/store/h6351wyaf8gahx46y71vd1200wr5l9gv-emacs-org-9.6.12/share/emac

2023-12-18 Thread Ihor Radchenko
"Dr. Arne Babenhauserheide"  writes:

> M-x org-toggle-debug-on-quit
>
>
> Debugger entered--Lisp error: (quit)
>   org-element--parse-to(13994)
>   org-element-at-point()
>   org--collect-keywords-1(("SETUPFILE" "BIND") nil nil 
> ("/home/arne/Schreibtisch/arnebab-org/politik/geschl...") nil)
>   org-collect-keywords(("BIND"))
>   org-export--list-bound-variables()

I am confused. Does it mean that you can reproduce the error manually,
not from Makefile?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] cannot export org-file: Warning (org-element-cache): org-element--cache: Got empty parent while parsing [9.6.12 (N/A @ /gnu/store/h6351wyaf8gahx46y71vd1200wr5l9gv-emacs-org-9.6.12/share/emac

2023-12-18 Thread Dr. Arne Babenhauserheide

Ihor Radchenko  writes:

> I downloaded the files, adjusted paths, and tried to export the main org
> file to html and latex. It was successfully export using the latest
> bugfix and main branches.
>
> May you please provide more details? Ideally, a recipe starting from
> emacs -Q. See https://orgmode.org/manual/Feedback.html#Feedback

I run the export from the Makefile via an adjusted HOME:

sitemap.org: site/.published
site/.published: index.org external-rss.org $(arnebab_DATA) setup.el 
.emacs.d/init.el ## create and publish the site according to setup.el
echo -e Yes\\nYes > $$(tty) ; time HOME="$(realpath 
@abs_top_builddir@)" timeout 360 emacs --load .emacs.d/init.el --load setup.el 
"$<" --eval "(setq org-babel-ditaa-java-cmd 
\"LD_LIBRARY_PATH=$${LD_LIBRARY_PATH}:$$HOME/.guix-profile/lib/ java\" 
plantuml-executable-path \"plantuml\" org-plantuml-jar-path 
\"$${GUIX_ENVIRONMENT=/home/$(whoami)/.guix-profile}/share/java/plantuml.jar\" 
org-plantuml-exec-mode 'plantuml)" --eval '(org-publish-current-project 
"arnebab-org")' -f kill-emacs && touch "$@" < $$(tty) > build.log && rm -f 
site/*~ site/*/*~ site/*/*/*~ site/*/*/*/*~

I already tried to find the cause — I can publish it from my regular
Emacs, but not from the stripped down version in the repository.

I created a backtrace via

M-x org-toggle-debug-on-quit


Debugger entered--Lisp error: (quit)
  org-element--parse-to(13994)
  org-element-at-point()
  org--collect-keywords-1(("SETUPFILE" "BIND") nil nil 
("/home/arne/Schreibtisch/arnebab-org/politik/geschl...") nil)
  org-collect-keywords(("BIND"))
  org-export--list-bound-variables()
  org-export--generate-copy-script(# 
:copy-unreadable do-not-check :drop-visibility nil :drop-narrowing nil 
:drop-contents nil :drop-locals nil)
  org-export-copy-buffer(:to-buffer nil :drop-visibility nil :drop-narrowing 
nil :drop-contents nil :drop-locals nil)
  org-export-as(html nil nil nil (:output-file 
"geschlechtsneutrale-sprache.html"))
  org-export-to-file(html "geschlechtsneutrale-sprache.html" nil nil nil nil 
nil)
  org-html-export-to-html(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  command-execute(org-export-dispatch)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


Re: [BUG] cannot export org-file: Warning (org-element-cache): org-element--cache: Got empty parent while parsing [9.6.12 (N/A @ /gnu/store/h6351wyaf8gahx46y71vd1200wr5l9gv-emacs-org-9.6.12/share/emac

2023-12-18 Thread Ihor Radchenko
"Dr. Arne Babenhauserheide"  writes:

> I have a file I currently cannot export (I get an infinite loop). The
> error message is:
>
> Warning (org-element-cache): org-element--cache: Got empty parent while 
> parsing. Please report it to Org mode mailing list (M-x 
> org-submit-bug-report).
>
> The org-file is:
> https://hg.sr.ht/~arnebab/draketo/browse/politik/geschlechtsneutrale-sprache.org
>
> It uses the setupfile:
> https://hg.sr.ht/~arnebab/draketo/browse/org-templates/level-1.org?rev=tip
>
> and includes:
> https://hg.sr.ht/~arnebab/draketo/browse/org-templates/level-1-politik.org?rev=tip

I downloaded the files, adjusted paths, and tried to export the main org
file to html and latex. It was successfully export using the latest
bugfix and main branches.

May you please provide more details? Ideally, a recipe starting from
emacs -Q. See https://orgmode.org/manual/Feedback.html#Feedback

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[SUMMARY] #4 [[bbb:OrgMeetup]] on Wed, Dec 13, 19:00 UTC+3

2023-12-18 Thread Ihor Radchenko


Here is a short summary of the main discussion points (those that I
remember):

- We started late, and the meeting was a bit chaotic this time. But
  also a bit more relaxing as we just had a few people, with just me
  and Matt discussing ob-shell development towards the end.

- Sacha Chua mentioned her recent work on EmacsConf and blog posts on
  automating video uploads to YouTube and Toobnix from Elisp:
  - 
https://sachachua.com/blog/2023/12/updating-youtube-videos-via-the-youtube-data-api-using-emacs-lisp-and-url-http-oauth/
  - 
https://sachachua.com/blog/2023/12/emacsconf-backstage-making-a-play-list-checking-it-twice/
  - 
https://sachachua.com/blog/2023/12/emacsconf-backstage-using-spookfox-to-publish-youtube-and-toobnix-video-drafts/
- She also hinted that she has many Emacs-related ideas accumulated over
  the busy recent years waiting to be tried. ... The old good PIM debt:
  https://karl-voit.at/Nobodys-PIM-is-perfect/
- Me, kickingvegas, and exc (matt) [ob-shell maintainer] discussed
  about using Org mode on mobile
  - We have a number of Android, iOS, and web apps these days:
- Emacs master has experimental Android support; one can use Org mode 
natively on Android
  - Serious usage is easier with USB-C or bluetooth keyboard though
  - But one can hack around toolbar to, for example, read through
the notes and execute code blocks
- https://beorgapp.com/
- https://xenodium.com/an-ios-journaling-app-powered-by-org-plain-text/
- recent https://github.com/Artawower/orgnote
  - This one is promising (although early in development) as it aims for
1. org-roam-ui interface for android and web (in future, for iOS)
2. crdt-inspired synchronization for more accurate conflict resolution
   - see https://emacsconf.org/2023/talks/collab/ for how powerful crdt 
can be
   - https://elpa.gnu.org/packages/crdt.html
- kickingvegas mentioned that using mobile phone for taking notes
  in Org is not yet ideal - the existing apps do not have the
  state-of-art UI
- mobile Org apps are still handy when one needs to get access to
  agenda view/calendar/quick notes on-the-go
- Someone implemented ncurses interface for Org mode: 
https://www.youtube.com/watch?v=QgYhuPgbp3s
  - Not clear why it should be better than terminal Emacs, but crazy
times ... (we did not actually watch the video though XD)
- We discussed Org mode implementations outside Emacs - there are plenty
  - Multiple Org mode implementations for Vim/Neovim
- https://github.com/nvim-orgmode/orgmode 
(https://github.com/milisims/tree-sitter-org)
- https://github.com/jceb/vim-orgmode
- https://github.com/nvim-orgmode/orgmode
  - https://github.com/vscode-org-mode/vscode-org-mode
  - Github partially supports Org mode markup
  - Hugo (note: *not* ox-hugo, but the proper Hugo static blog generator) also 
supports Org mode natively
- https://gohugo.io/content-management/formats/
  - Hugo uses one of many Org mode parser libraries 
https://github.com/niklasfasching/go-org
  - That's why Org mode is moving towards more standard and stable syntax 
definition
- https://list.orgmode.org/orgmode/871rjhha8t@gmail.com/
  (submit an IETF RFC to register Org as a MIME type)
- https://orgmode.org/worg/org-syntax.html
- There is also Karl Voit's idea about defining subsets of Org
  syntax for easier implementation
  - 
https://gitlab.com/publicvoit/orgdown/-/blob/master/doc/Orgdown-Levels.org
  - https://emacsconf.org/2021/talks/org-outside/
- I mentioned how I manage Org mode-related news from Reddit, blogs,
  Mastodon, and track development of Org mode-related libraries
  - In short, I simply use elfeed - https://github.com/skeeto/elfeed
  - Pretty much all the forges and forums provide RSS feeds that can be added 
to Elfeed
- Examples:
  https://github.com/org-roam/org-roam/commits.atom
  https://git.sr.ht/~bzg/worg/log/master/rss.xml
  https://gitlab.com/hperrey/org-jami-bot/-/commits/main?format=atom
  https://codeberg.org/martianh/mastodon.el.rss
  https://old.reddit.com/user/yantar92/.rss (user feed)
  https://old.reddit.com/r/orgmode/.rss (subreddit feed)
  https://planet.emacslife.com/atom.xml
  https://emacs.ch/@sachac.rss (user)
  https://emacs.ch/@emacs.rss (tracking everything tagged #emacs)
  - A note on RSS feeds for Mastodon: they do not have titles,
making it awkward to eyeball in Elfeed (they appear as empty
lines)
- I use a customization to swap contents and title for such feeds
  
https://github.com/yantar92/emacs-config/blob/master/config.org#custom-title-formatting
  - And when an RSS feed is not available, there is https://docs.rsshub.app/
(can be self-hosted in Docker)

- ob-shell maintainer shared his recent background work on
  lisp/ob-shell.el, in a form of Org notes. The notes may eventually
  be shared to public.
  - 

Re: #4 [[bbb:OrgMeetup]] on Wed, Dec 13, 19:00 UTC+3

2023-12-18 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> Time & Date: <2023-12-13 Wed 19:00-21:00 @+03,Europe/Istanbul>
>
> When I click on the timestamp above, Org says:
>
>   This should not happen
>
> Is that normal?

Yes, it is. Because Org timestamps do not yet allow time zone
specification.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [Patch] Adding support for arxiv type link

2023-12-18 Thread Ihor Radchenko
Hammer Hu  writes:

> I made several commit adding support for link as arxiv:2208.11710. These codes
> basically come from lisp/ol-doi.el. I copy and modify them side by side. Let 
> me
> know what do you think!

Thanks for the patch, but may you please explain why you need a new link
type rather than simply using link abbreviation as described in
https://orgmode.org/manual/Link-Abbreviations.html

#+LINK: arxiv  https://arxiv.org/abs/

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Justify/align image previews in org-mode

2023-12-18 Thread Ihor Radchenko
Karthik Chikmagalur  writes:

> Please ignore the previous patch and use this one instead.  I've fixed a
> bug and a couple of formatting errors.

Thanks for the patch!
See my comments inline.

> +(defcustom org-image-align nil
> +  "How to align images previewed using `org-display-inline-images'.
> +
> +Only stand-alone image links are affected by this setting.  These
> +are links without surrounding text.
> +
> +Possible values of this option are:
> +
> +nil  Insert image at specified position (same as left-alignment).

It would make sense to allow 'left value as well (same as nil).

> +  (when align
> +(overlay-put
> + ov 'before-string
> + (propertize
> +  " " 'face 'default
> +  'display
> +  (pcase align
> +((or 'center 'justify)

I do not think that we need to consider 'justify value at this point.
Maybe in future, when (or if) we add proper justification support to
text. But not now.

> +(defun org-image--align (link)
> +  "Determine the alignment of the image link.
> +
> +This is controlled globally by the option `org-image-align', and
> +per image by the value of `:align' in the affiliated keyword
> +`#+attr_org'.
> +
> +The result is one of the symbols center, justify or right.  The
> +first two will cause the image preview to be centered, the last
> +will cause it to be right-aligned.  A return value of nil implies
> +no special alignment -- the image preview is overlaid on the link
> +exactly where it appears in the buffer."
> +  (let ((par (org-element-lineage link 'paragraph)))
> +;; Only apply when image is not surrounded by paragraph text:
> +(when (and (= (org-element-property :begin link)
> +  (org-element-property :contents-begin par))
> +   (<= (- (org-element-property :contents-end par)
> +  (org-element-property :end link))
> +   1))  ;account for trailing newline

This will not work when the image paragraph is indented:

* This is test
  #+attr_org: :align center
  [[file:~/Downloads/wallpaper.png]]

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH v2] org-id: allow using parent's existing id in links to headlines

2023-12-18 Thread Ihor Radchenko
"Rick Lupton"  writes:

> Please find attached updated patch which I think addresses all the points 
> discussed.  Let me know if you see any further changes needed.

Thanks!

I played around with the patch a bit and found a couple of rough edges:

1. When I try to open a link to non-existing search target, like
   , I get a query to create a new
   heading. If I reply "yes", a new heading is created. However, the
   heading is created at the end of the file and is always level 1,
   regardless of the "some-id" parent context.
   It would make more sense to create a new heading at the end of the
   id:some-id subtree.

2. Consider the following setting:
   (setq org-id-link-consider-parent-id t)
   (setq org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id)

   Then, create the following Org file

* Sub
* Parent here
** This is test
:PROPERTIES:
:ID:   fe40252e-0527-44c1-a990-12498991f167
:END:

*** Sub 
:PROPERTIES:
:CUSTOM_ID:   subid
:END:

   When you M-x org-store-link, the stored link has ::*Sub instead of
   the expected ::#subid

3. Consider
   (setq org-id-link-consider-parent-id t)
   (setq org-id-link-to-org-use-id t)

   Then, create a new empty Org file
   M-x org-store-link with create a top-level properties drawer with ID
   and store the link. However, that link will not be a simple ID link,
   but also have ::PROPERTIES search string, which is not expected.

More inline comments below.

> +  #+vindex: org-id-link-consider-parent-id
> +  When ~org-id-link-consider-parent-id~ is ~t~, parent =ID= properties
> +  are considered.  This allows linking to specific targets, named
> +  blocks, or headlines (which may not have a globally unique =ID=
> +  themselves) within the context of a parent headline or file which
> +  does.

It would be nice to add an example, similar to what you did in the docstring.

> -(defun org-man-store-link ()
> +(defun org-man-store-link ( _interactive?)
>"Store a link to a man page."
>(when (memq major-mode '(Man-mode woman-mode))
>  ;; This is a man page, we do make this link.
> @@ -21312,13 +21324,15 @@ A review of =ol-man.el=:

Please, update the actual built-in :store functions in lisp/ol-*.el to
handle the new optional argument as well.

> + =org-link= store functions are passed an ~interactive?~ argument
> +
> +The ~:store:~ functions set for link types using
> +~org-link-set-parameters~ are now passed an ~interactive?~ argument,
> +indicating whether ~org-store-link~ was called interactively.

Please also explain that the existing functions are not broken.

> +*** ~org-id-store-link~ now adds search strings for precise link targets
> +
> +This new behaviour can be disabled generally by setting
> +~org-id-link-use-context~ to ~nil~, or when storing a specific link by
> +passing a prefix argument to ~org-store-link~.

universal argument.
There are several possible prefix arguments in `org-store-link', but
only C-u (universal argument) will give the described effect.
Also, won't the behavior be _toggled_ by the universal argument?

> +When using this feature, IDs should not include =::=, which is used in
> +links to indicate the start of the search string.  For backwards
> +compability, existing IDs including =::= will still be matched (but
> +cannot be used together with precise link targets).

Please add an org-lint checker that warns about such IDs and mention
this checker in the above.
Also, this paragraph belongs to "Breaking changes", not "new and changed
options".

> +*** New option ~org-id-link-consider-parent-id~ to allow =id:= links to 
> parent headlines
> +
> +For =id:= links, when this option is enabled, ~org-store-link~ will
> +look for ids from parent/ancestor headlines, if the current headline
> +does not have an id.
> +
> +Combined with the new ability for =id:= links to use search strings
> +for precise link targets (when =org-id-link-use-context= is =t=, which
> +is the default), this allows linking to specific headlines without
> +requiring every headline to have an id property, as long as the
> +headline is unique within a subtree that does have an id property.
> +
> +By giving files top-level id properties, links to headlines in the
> +file can be made more robust by using the file id instead of the file
> +path.

Please, provide an example here as well.

> +(defun org-link--try-link-store-functions (interactive?)
> +  "Try storing external links, prompting if more than one is possible.
> +
> +Each function returned by `org-store-link-functions' is called in
> +turn.  If multiple functions return non-nil, prompt for which
> +link should be stored.
> +
> +Return t when a link has been stored in `org-link-store-props'."

Please document INTERACTIVE? argument in the docstring.

> +  (let ((results-alist nil))
> +(dolist (f (org-store-link-functions))
> +  (when (condition-case nil
> +(funcall f interactive?)
> +  ;; XXX: The store function used (< Org 9.7) to accept no
> + 

[BUG] cannot export org-file: Warning (org-element-cache): org-element--cache: Got empty parent while parsing [9.6.12 (N/A @ /gnu/store/h6351wyaf8gahx46y71vd1200wr5l9gv-emacs-org-9.6.12/share/emacs/si

2023-12-18 Thread Dr. Arne Babenhauserheide


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

 https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


I have a file I currently cannot export (I get an infinite loop). The
error message is:

Warning (org-element-cache): org-element--cache: Got empty parent while 
parsing. Please report it to Org mode mailing list (M-x org-submit-bug-report).

The org-file is:
https://hg.sr.ht/~arnebab/draketo/browse/politik/geschlechtsneutrale-sprache.org

It uses the setupfile:
https://hg.sr.ht/~arnebab/draketo/browse/org-templates/level-1.org?rev=tip

and includes:
https://hg.sr.ht/~arnebab/draketo/browse/org-templates/level-1-politik.org?rev=tip

Best wishes,
Arne

Emacs  : GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, 
cairo version 1.16.0)
Package: Org mode version 9.6.12 (N/A @ 
/gnu/store/h6351wyaf8gahx46y71vd1200wr5l9gv-emacs-org-9.6.12/share/emacs/site-lisp/org-9.6.12/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-html-mathjax-template "\n
MathJax.Hub.Config({\ndisplayAlign: \"%ALIGN\",\ndisplayIndent: 
\"%INDENT\",\n\n\"HTML-CSS\": { scale: %SCALE,\n
linebreaks: { automatic: \"%LINEBREAKS\" },\nwebFont: 
\"%FONT\"\n   },\nSVG: {scale: %SCALE,\n
  linebreaks: { automatic: \"%LINEBREAKS\" },\n  font: 
\"%FONT\"},\nNativeMML: {scale: %SCALE},\nTeX: { 
equationNumbers: {autoNumber: \"%AUTONUMBER\"},\n   MultLineWidth: 
\"%MULTLINEWIDTH\",\n   TagSide: \"%TAGSIDE\",\n   
TagIndent: \"%TAGINDENT\"\n }\n});\n\n"
 org-bibtex-headline-format-function #[257 "\300%1\236A\207" [:title] 3 
"\n\n(fn ENTRY)"]
 org-publish-project-alist '(("arnebab-org-serviceworker" :base-directory
  "/home/arne/Schreibtisch/arnebab-org/"
  :publishing-directory
  "/home/arne/Schreibtisch/arnebab-org/site/"
  :base-extension "js" :recursive nil
  :publishing-function org-publish-attachment 
:include
  ["sw.js"])
 ("arnebab-org-static-wissen" :base-directory
  "/home/arne/Schreibtisch/arnebab-org/wissen"
  :publishing-directory
  "/home/arne/Schreibtisch/arnebab-org/site/wissen"
  :base-extension
  
"css\\|js\\|png\\|jpg\\|gif\\|avif\\|webp\\|svg\\|pdf\\|m3u\\|mp3\\|ogg\\|swf\\|webm\\|opus\\|dat\\|txt\\|scm\\|w"
 :recursive t :publishing-function org-publish-attachment :exclude 
"org-templates\\|.*html\\|.*~\\|site\\|\\..*emacs\\.d\\|org-timestamps\\|arnebab-[0-9]\\.[0-9]\\.[0-9]")
 ("arnebab-org-static-software" :base-directory
  "/home/arne/Schreibtisch/arnebab-org/software"
  :publishing-directory
  
"/home/arne/Schreibtisch/arnebab-org/site/software"
  :base-extension
  
"css\\|js\\|png\\|jpg\\|gif\\|avif\\|webp\\|svg\\|pdf\\|m3u\\|mp3\\|ogg\\|swf\\|webm\\|opus\\|dat\\|txt\\|scm\\|w"
 :recursive t :publishing-function org-publish-attachment :exclude 
"org-templates\\|.*html\\|.*~\\|site\\|\\..*emacs\\.d\\|org-timestamps\\|arnebab-[0-9]\\.[0-9]\\.[0-9]")
 ("arnebab-org-static-rollenspiel" :base-directory
  "/home/arne/Schreibtisch/arnebab-org/rollenspiel"
  :publishing-directory
  
"/home/arne/Schreibtisch/arnebab-org/site/rollenspiel"
  :base-extension
  
"css\\|js\\|png\\|jpg\\|gif\\|avif\\|webp\\|svg\\|pdf\\|m3u\\|mp3\\|ogg\\|swf\\|webm\\|opus\\|dat\\|txt\\|scm\\|w"
 :recursive t :publishing-function org-publish-attachment :exclude 
"org-templates\\|.*html\\|.*~\\|site\\|\\..*emacs\\.d\\|org-timestamps\\|arnebab-[0-9]\\.[0-9]\\.[0-9]")
 ("arnebab-org-static-politik" :base-directory
  "/home/arne/Schreibtisch/arnebab-org/politik"
  :publishing-directory
  "/home/arne/Schreibtisch/arnebab-org/site/politik"
  :base-extension
  
"css\\|js\\|png\\|jpg\\|gif\\|avif\\|webp\\|svg\\|pdf\\|m3u\\|mp3\\|ogg\\|swf\\|webm\\|opus\\|dat\\|txt\\|scm\\|w"
 :recursive t :publishing-function org-publish-attachment :exclude 

Re: [PATCH] Justify/align image previews in org-mode

2023-12-18 Thread Karthik Chikmagalur
Please ignore the previous patch and use this one instead.  I've fixed a
bug and a couple of formatting errors.

Karthik
diff --git a/lisp/org.el b/lisp/org.el
index 30a4e7aef..ad2ad2332 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15673,6 +15673,25 @@ cache   Display remote images, and open them in separate buffers
 	  (const :tag "Display and silently update remote images" cache))
   :safe #'symbolp)
 
+(defcustom org-image-align nil
+  "How to align images previewed using `org-display-inline-images'.
+
+Only stand-alone image links are affected by this setting.  These
+are links without surrounding text.
+
+Possible values of this option are:
+
+nil  Insert image at specified position (same as left-alignment).
+center   Center image previews.
+rightRight-align image previews."
+  :group 'org-appearance
+  :package-version '(Org . "9.7")
+  :type '(choice
+  (const :tag "Don\\='t align image previews" nil)
+	  (const :tag "Center image previews" center)
+	  (const :tag "Right align image previews" right))
+  :safe #'symbolp)
+
 (defun org--create-inline-image (file width)
   "Create image located at FILE, or return nil.
 WIDTH is the width of the image.  The image may not be created
@@ -15807,7 +15826,8 @@ buffer boundaries with possible narrowing."
   (when file (setq file (substitute-in-file-name file)))
 		  (when (and file (file-exists-p file))
 		(let ((width (org-display-inline-image--width link))
-			  (old (get-char-property-and-overlay
+			  (align (org-image--align link))
+  (old (get-char-property-and-overlay
 (org-element-begin link)
 'org-image-overlay)))
 		  (if (and (car-safe old) refresh)
@@ -15833,6 +15853,16 @@ buffer boundaries with possible narrowing."
 			   (list 'org-display-inline-remove-overlay))
 			  (when (boundp 'image-map)
 (overlay-put ov 'keymap image-map))
+  (when align
+(overlay-put
+ ov 'before-string
+ (propertize
+  " " 'face 'default
+  'display
+  (pcase align
+((or 'center 'justify)
+ `(space :align-to (- center (0.5 . ,image
+('right  `(space :align-to (- right ,image)))
 			  (push ov org-inline-image-overlays
 
 (defvar visual-fill-column-width) ; Silence compiler warning
@@ -15894,6 +15924,37 @@ buffer boundaries with possible narrowing."
   org-image-actual-width)
  (t nil
 
+(defun org-image--align (link)
+  "Determine the alignment of the image link.
+
+This is controlled globally by the option `org-image-align', and
+per image by the value of `:align' in the affiliated keyword
+`#+attr_org'.
+
+The result is one of the symbols center, justify or right.  The
+first two will cause the image preview to be centered, the last
+will cause it to be right-aligned.  A return value of nil implies
+no special alignment -- the image preview is overlaid on the link
+exactly where it appears in the buffer."
+  (let ((par (org-element-lineage link 'paragraph)))
+;; Only apply when image is not surrounded by paragraph text:
+(when (and (= (org-element-property :begin link)
+  (org-element-property :contents-begin par))
+   (<= (- (org-element-property :contents-end par)
+  (org-element-property :end link))
+   1))  ;account for trailing newline
+  (save-match-data
+;; Look for a valid :align keyword (left, center, justify or right)
+(if-let* ((attr-org (car-safe (org-element-property :attr_org par)))
+  ((string-match ":align[[:space:]]+\\(\\w+\\)" attr-org))
+  (attr-align (car-safe
+   (memq (intern (match-string 1 attr-org))
+ '(left center justify right)
+(unless (eq attr-align 'left) attr-align)
+  ;; No image-specific keyword, check global alignment property
+  (when (memq org-image-align '(center justify right))
+org-image-align))
+
 (defun org-display-inline-remove-overlay (ov after _beg _end  _len)
   "Remove inline-display overlay if a corresponding region is modified."
   (when (and ov after)