Re: [ANN] lisp/ob-tangle-sync.el

2024-04-28 Thread João Pedro
Hey Mehmet and Org!

I'd like to ask if I could contribute to this. I have followed the
discussion to a point, but would be more than happy to try and
contribute to this so it gets merged for the next Org major version, as
I've been waiting for this for quite a while now. It solves the major
gripe I had with your original org-tangle-sync.el package, which is the
ability to sync blocks that aren't whole files.

So, what still needs to be done and where is development happening (I
assumed it was on the main Org-mode git repository, but I see no branch
there)?

Cheers,

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


Re: Adding custom providers for thingatpt.el (was: [PATCH] Add support for 'thing-at-point' to get URL at point)

2024-04-28 Thread Jim Porter

On 4/12/2024 3:30 PM, Jim Porter wrote:

On 4/12/2024 5:41 AM, Ihor Radchenko wrote:

Jim Porter  writes:


That sounds reasonable enough to me; does anyone else have opinions on
this? Otherwise, I'll get to work on a patch (though probably not for a
couple weeks).


It has been a while since the last message in this thread.
Jim, may I know if you had a chance to work on the patch?


Sorry about that. I'm currently extremely swamped with real life, but 
most of that should be wrapped up by the end of the month, at which 
point I'll be able to devote some time to Emacs again.


Ihor, Eli: What do you think of the attached patch? I added variables to 
let modes define custom providers for 'bounds-of-thing-at-point' and 
'forward-thing'. (Notably, I avoided adding vars for the 
'beginning-of-thing' and 'end-of-thing' functions, since those just call 
'bounds-of-thing-at-point' anyway.)


If this looks like a reasonable way to go, I'll continue work on this 
patch by adding entries to 'bounds-of-thing-at-point-provider-alist' and 
'forward-thing-provider-alist' in the appropriate places (i.e. wherever 
we already add to 'thing-at-point-provider-alist', like in EWW).From a0ed62aa42fa47043511ba814cf5ce8419e9d03f Mon Sep 17 00:00:00 2001
From: Jim Porter 
Date: Sun, 28 Apr 2024 21:19:53 -0700
Subject: [PATCH] Allow defining custom providers for more "thingatpt"
 functions

* lisp/thingatpt.el (bounds-of-thing-at-point-provider-alist)
(forward-thing-provider-alist): New variables...
(forward-thing, bounds-of-thing-at-point): ... use them.
* test/lisp/thingatpt-tests.el (thing-at-point-providers)
(forward-thing-providers, bounds-of-thing-at-point-providers): New
tests.

* etc/NEWS: Announce this change.
---
 etc/NEWS | 18 +-
 lisp/thingatpt.el| 35 ++-
 test/lisp/thingatpt-tests.el | 31 +++
 3 files changed, 74 insertions(+), 10 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 7efb4110bcd..2480f0d096d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1591,19 +1591,27 @@ of the currently existing keyboards macros using the 
new mode
 duplicating them, deleting them, and editing their counters, formats,
 and keys.
 
-** Miscellaneous
+** thingatpt.el
 
 ---
-*** Webjump now assumes URIs are HTTPS instead of HTTP.
-For links in 'webjump-sites' without an explicit URI scheme, it was
-previously assumed that they should be prefixed with "http://;.  Such
-URIs are now prefixed with "https://; instead.
+*** New variables for providing custom thingatpt implementations.
+The new variables 'bounds-of-thing-at-point-provider-alist' and
+'forward-thing-provider-alist' now allow defining custom implementations
+of 'bounds-of-thing-at-point' and 'forward-thing', respectively.
 
 ---
 *** 'bug-reference-mode' now supports 'thing-at-point'.
 Now, calling '(thing-at-point 'url)' when point is on a bug reference
 will return the URL for that bug.
 
+** Miscellaneous
+
+---
+*** Webjump now assumes URIs are HTTPS instead of HTTP.
+For links in 'webjump-sites' without an explicit URI scheme, it was
+previously assumed that they should be prefixed with "http://;.  Such
+URIs are now prefixed with "https://; instead.
+
 +++
 *** New user option 'rcirc-log-time-format'
 This allows for rcirc logs to use a custom timestamp format, than the
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 7896ad984df..d5f71e3c6a8 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -75,6 +75,22 @@ thing-at-point-provider-alist
 `existing-filename', `url', `email', `uuid', `word', `sentence',
 `whitespace', `line', `face' and `page'.")
 
+(defvar bounds-of-thing-at-point-provider-alist nil
+  "Alist of providers to return the bounds of a \"thing\" at point.
+This variable can be set globally, or appended to buffer-locally by
+modes, to provide functions that will return the bounds of a \"thing\"
+at point.  The first provider for the \"thing\" that returns a non-nil
+value wins.  You can use this in much the same way as
+`thing-at-point-provider-alist' (which see).")
+
+(defvar forward-thing-provider-alist nil
+  "Alist of providers for moving forward to the end of a \"thing\".
+This variable can be set globally, or appended to buffer-locally by
+modes, to provide functions that will move forward to the end of a
+\"thing\" at point.  The first provider for the \"thing\" that returns a
+non-nil value wins.  You can use this in much the same way as
+`thing-at-point-provider-alist' (which see).")
+
 ;; Basic movement
 
 ;;;###autoload
@@ -84,11 +100,16 @@ forward-thing
 Possibilities include `symbol', `list', `sexp', `defun', `number',
 `filename', `url', `email', `uuid', `word', `sentence', `whitespace',
 `line', and `page'."
-  (let ((forward-op (or (get thing 'forward-op)
-   (intern-soft (format "forward-%s" thing)
-(if (functionp forward-op)
-   (funcall forward-op (or n 1))
-  (error "Can't determine how 

Possible to set block switches "globally"?

2024-04-28 Thread João Pedro
Hi Org-mode!

Is there a way to set =src= and =example= switches (as documented in
"(org) Literal Examples"[0]) file- or heading-wide? I tried using

#+property: header-args:emacs-lisp -n -r

but they aren't really header arguments and that doesn't get picked up
as it should (it does, but as if `-n' is a key and `-r' is a value for a
header argument).

Ideally, I would be able to set those as a file properties like that, or
per heading under the =:PROPERTIES:= drawer.

[0] https://orgmode.org/manual/Literal-Examples.html

Thanks in advance,

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


Possible to set block switches "globally"?

2024-04-28 Thread João Pedro
Hi Org-mode!

Is there a way to set =src= and =example= switches (as documented in
"(org) Literal Examples"[0]) file- or heading-wide? I tried using

#+property: header-args:emacs-lisp -n -r

but they aren't really header arguments and that doesn't get picked up
as it should (it does, but as if `-n' is a key and `-r' is a value for a
header argument).

Ideally, I would be able to set those as a file properties like that, or
per heading under the =:PROPERTIES:= drawer.

Thanks in advance,

[0] https://orgmode.org/manual/Literal-Examples.html

-- 
João Pedro de A. Paula
IT bachelors at Universidade Federal do Rio Grande do Norte (UFRN)


[PATCH] lisp/org.el: Obsolete `org-cached-entry-get' in favor of `org-entry-get'

2024-04-28 Thread Morgan Smith
* lisp/org.el (org-cached-entry-get): Rewrite in terms
`org-entry-get'.  Obsolete in favor of `org-entry-get'.
(org-make-tags-matcher): Replace uses of `org-cached-entry-get' with
`org-entry-get'.
---
Hello!

All tests pass.

I don't think we can justify the existence of this function but let me know if
I'm wrong.

The caching mechanism used here is likely to cause hard to diagnose issues.

All of the logic here already exists in `org-entry-get'.

This function is mentioned in very few commits unlike its more popular sibling.

Thanks,

Morgan

 lisp/org.el | 21 +
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index c91029c7f..80ffeeccf 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11480,21 +11480,10 @@ are also TODO tasks."
 
 (defalias 'org-tags-sparse-tree 'org-match-sparse-tree)
 
-(defvar org-cached-props nil)
 (defun org-cached-entry-get (pom property)
-  (if (or (eq t org-use-property-inheritance)
- (and (stringp org-use-property-inheritance)
-  (let ((case-fold-search t))
-(string-match-p org-use-property-inheritance property)))
- (and (listp org-use-property-inheritance)
-  (member-ignore-case property org-use-property-inheritance)))
-  ;; Caching is not possible, check it directly.
-  (org-entry-get pom property 'inherit)
-;; Get all properties, so we can do complicated checks easily.
-(cdr (assoc-string property
-  (or org-cached-props
-  (setq org-cached-props (org-entry-properties pom)))
-  t
+  (org-entry-get pom property 'selective))
+
+(make-obsolete 'org-cached-entry-get "use `org-entry-get' instead." "9.7")
 
 (defun org-global-tags-completion-table ( files)
   "Return the list of all tags in all agenda buffer/files.
@@ -11670,7 +11659,7 @@ See also `org-scan-tags'."
   ("CATEGORY"
'(org-get-category (point)))
   ("TODO" 'todo)
-  (p `(org-cached-entry-get nil ,p
+  (p `(org-entry-get (point) ,p 'selective
 ;; Determine operand (aka. property
 ;; value).
 (pv (match-string 8 term))
@@ -11707,7 +11696,7 @@ See also `org-scan-tags'."
  (setq term rest)))
  (push `(and ,@tagsmatcher) orlist)
  (setq tagsmatcher nil))
-   (setq tagsmatcher `(progn (setq org-cached-props nil) (or ,@orlist)
+   (setq tagsmatcher `(or ,@orlist
 
 ;; Make the TODO matcher.
 (when (org-string-nw-p todomatch)
-- 
2.41.0




[PATCH] org-make-tags-matcher: Compile returned function

2024-04-28 Thread Morgan Smith
This should result in a nice performance boost when the function is
called repeatedly (as is often done).

* lisp/org.el (org-make-tags-matcher): Evaluate returned function to
compile it into a closure.
---

Hello!

All tests pass.

I don't have any rigorous benchmarks but this does make things significantly
faster.  This actually seems to have a bigger performance impact on
`org-clock-sum' then my rewrite of `org-clock-sum' I submitted earlier does.
Which is a little frustrating honestly.

It does involve using the `eval' function which I know is a little taboo.
Although in this case I don't believe it actually adds any danger.

Thanks,

Morgan

 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 084132fb3..80ffeeccf 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11726,7 +11726,7 @@ See also `org-scan-tags'."
 (or tagsmatcher todomatcher t
   (when org--matcher-tags-todo-only
(setq matcher `(and (member todo org-not-done-keywords) ,matcher)))
-  (cons match0 `(lambda (todo tags-list level) ,matcher)
+  (cons match0 (eval `(lambda (todo tags-list level) ,matcher) t)
 
 (defun org--tags-expand-group (group tag-groups expanded)
   "Recursively expand all tags in GROUP, according to TAG-GROUPS.
-- 
2.41.0




Re: [FR] Support headline as a function for file+headline target for org-capture-templates

2024-04-28 Thread Nafiz Islam
> Upon closer look at the `org-capture`, `org-capture-set-target-location`
and `org-capture-place-entry`, I'm starting to realize that "file+function"
can be used for what I'm looking for. I was just worried about the use of
`(org-capture-put :exact-position (point))`

My disappointing attempt at using file+function target to replicate my idea

(defun my/diary-capture-find-headline ()
(let* ((entries (org-map-entries (lambda ()
  (list (org-element-property :title (org-element-at-point))
(org-element-property :begin (org-element-at-point
"LEVEL=1"))
  (final-pos)
  (final-pos
   (dolist (entry entries final-pos)
 (pcase-let ((`(,title ,begin) entry))
(let* ((diff-time (time-subtract (current-time) (org-time-string-to-time
title)))
  (diff-secs (nth 1 diff-time))
  (5-mins-in-secs (* 5 60)))
 (if (< diff-secs 5-mins-in-secs)
 (setq final-pos (goto-char begin))
   final-pos))
  (unless final-pos
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(insert "\n* ")
(let ((current-prefix-arg '(16)))
 (call-interactively #'org-time-stamp-inactive))
(beginning-of-line

(setopt org-capture-templates
  '(("d" "Diary Template" entry
 (file (lambda () (expand-file-name
   (concat org-directory "Diary" "/" (format-time-string "%Y-%m-%d.org")
 "* %U\n%?"
:empty-lines 1)
("p" "Diary Item Capture Test" item
 (file+function (lambda () (expand-file-name
   (concat org-directory "Diary" "/" (format-time-string "%Y-%m-%d.org"
   my/diary-capture-find-headline)
"- %?"
:empty-lines 0)))


[BUG] Attachments not resolved correctly from symlinked Org files

2024-04-28 Thread Karthik Chikmagalur
Attachment paths are not resolved correctly when the Org file is
symlinked elsewhere. This may or may not be a bug, but I think it's
undesired behavior:

1. Create an Org file somewhere, say ~/Desktop/test.org.

2. In test.org, create an attachment: `C-c C-a m' as a file.  Either the
   "copy" or "move" attachment method can be used.

3. Symlink test.org from elsewhere, say

/tmp/test.org -> ~/Desktop/test.org

4. In a fresh Emacs session, open /tmp/test.org and try to open the
attachment directory (`C-c C-a f').

Two things happen:

- An empty directory is created, like
  /tmp/data/48/2697ee-913c-4eee-b1fb-636416d3fb6b

- The original attachment can't be found, since it's actually in
  ~/Desktop/data/48/2697ee-913c-4eee-b1fb-636416d3fb6b

Tested with `emacs -q' with Org 9.6.23, and with commit
1ae978f940c0f88473f2232177c63a0de7fb7a1c from two weeks ago.

Karthik



Re: [BUG] oddity tangling src_blk with :var [9.7-pre (release_9.6.26-1368-g1ae978 @ /home/minshall/.emacs.d/straight/build/org/)]

2024-04-28 Thread Greg Minshall
hi, Ihor,

thanks for looking at this.

> This is because Org mode currently cannot distinguish between babel
> backends that simply do not support variable assignments and babel
> backends that are not loaded.

currently, is it possible to see well enough what is going on to
generate an error and abort the tangle?

(off the top of my head i would think a `:var` in either of the
situations you describe might be described as an error -- albeit a user
error.)

cheers, Greg



Re: [PATCH] org-ctags.el: Protect shell specials in directory name

2024-04-28 Thread Ihor Radchenko
Max Nikulin  writes:

>> Tests must be fully automated. We use make test in CI and things like
>> project-compile are non-interactive.
>
> I do not mind. Requiring unexpected user interactions is a feature of 
> org-ctags.

So, may you update the patch to make tests automated?

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



Re: [PATCH] org-ctags.el: Protect shell specials in directory name

2024-04-28 Thread Max Nikulin

On 28/04/2024 23:55, Ihor Radchenko wrote:

Max Nikulin  writes:


I tried to run make test with your patch applied, but I am getting
interactive prompt there:

  Visit tags table (default TAGS):


You may press RET...

It is due to invasive org-ctags behavior.


Tests must be fully automated. We use make test in CI and things like
project-compile are non-interactive.


I do not mind. Requiring unexpected user interactions is a feature of 
org-ctags.






Re: [PATCH] org-ctags.el: Protect shell specials in directory name

2024-04-28 Thread Ihor Radchenko
Max Nikulin  writes:

>> I tried to run make test with your patch applied, but I am getting
>> interactive prompt there:
>> 
>>  Visit tags table (default TAGS):
>
> You may press RET...
>
> It is due to invasive org-ctags behavior.

Tests must be fully automated. We use make test in CI and things like
project-compile are non-interactive.

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



Re: [PATCH] org-ctags.el: Protect shell specials in directory name

2024-04-28 Thread Max Nikulin

On 28/04/2024 19:53, Ihor Radchenko wrote:

May you submit a patch?

Max Nikulin writes:

See the attachments.


I tried to run make test with your patch applied, but I am getting
interactive prompt there:

 Visit tags table (default TAGS):


You may press RET...

It is due to invasive org-ctags behavior.

Nick Dokos. org-ctags land grab. Mon, 20 Mar 2023 23:36:09 -0400.
https://list.orgmode.org/87o7omg4ie@alphaville.usersys.redhat.com





Re: [FR] Support headline as a function for file+headline target for org-capture-templates

2024-04-28 Thread Nafiz Islam
Upon closer look at the `org-capture`, `org-capture-set-target-location`
and `org-capture-place-entry`, I'm starting to realize that "file+function"
can be used for what I'm looking for. I was just worried about the use of
`(org-capture-put :exact-position (point))`

On Sun, Apr 28, 2024 at 10:58 AM Nafiz Islam 
wrote:

> Right now, only the file name supports being either a string, symbol or
> function, etc. Nonetheless, it would be nice if headline could be a
> function that takes in as parameter a list of all headlines present in the
> file so that we can dynamically pick a headline under which we want to add
> an entry.  The function can also return a string to represent a
> (potentially) new headline to insert.
>
> My use case for that is I have an org file in which each headline is a
> specific time, and I want to reuse a headline that is only within 5 minutes
> behind the current time.
>
>


[FR] Support headline as a function for file+headline target for org-capture-templates

2024-04-28 Thread Nafiz Islam
Right now, only the file name supports being either a string, symbol or
function, etc. Nonetheless, it would be nice if headline could be a
function that takes in as parameter a list of all headlines present in the
file so that we can dynamically pick a headline under which we want to add
an entry.  The function can also return a string to represent a
(potentially) new headline to insert.

My use case for that is I have an org file in which each headline is a
specific time, and I want to reuse a headline that is only within 5 minutes
behind the current time.


Re: [DISCUSSION] Add "Recent News" to orgmode.org

2024-04-28 Thread Bastien Guerry
Ihor Radchenko  writes:

> Maybe we should add an equivalent of `worg-publish-stop-on-error' to
> orgweb publish process?

Good idea, done.  Let's see if it helps!

-- 
 Bastien Guerry



[BUG] ob-shell: internal representation of cmdline arguments the same

2024-04-28 Thread Matt
While investigating "[BUG] ob-shell: :shebang changes interpretation of 
:cmdline" 
(https://list.orgmode.org/orgmode/18f01342a2f.124ad27612732529.8693431365849276...@excalamus.com/),
 it was observed that :cmdline 1 2 3 behaves like :cmdline "1 2 3"

The first argument is the first space delimited character following ":cmdline":

#+begin_src bash :cmdline 1 2 3
echo "$1"
#+end_src

#+RESULTS:
: 1

The following makes it seem like command-line arguments may be grouped using 
quotes:

#+begin_src bash :cmdline "1 2" 3
echo "$1"
#+end_src

#+RESULTS:
: 1 2

The following demonstrates that quotes do not always indicate separate 
arguments:

#+begin_src bash :cmdline "1 2 3" 
echo "$1"
#+end_src

#+RESULTS:
: 1

It was stated that,

#+begin_quote
AFAICT, it's due to how headers are parsed by 
'org-babel-parse-header-arguments' using 'org-babel-read'. The cell "\"1 2 3\"" 
(corresponding to :cmdline "1 2 3") is reduced through 'string-match' to "1 2 
3". The cell "1 2 3" (corresponding to :cmdline 1 2 3), on the other hand, 
passes through. The result is that :cmdline "1 2 3" and :cmdline 1 2 3 become 
indistinguishable.
#+end_quote

Org mode version 9.7-pre (release_9.6.27-1393-ge0f24a @ 
/home/ahab/Projects/org-mode/lisp/), commit e0f24a3f6

--
Matt Trzcinski
Emacs Org contributor (ob-shell)
Learn more about Org mode at https://orgmode.org
Support Org development at https://liberapay.com/org-mode





[BUG] ob-shell: results missing leading quotes

2024-04-28 Thread Matt
While investigating "[BUG] ob-shell: :shebang changes interpretation of 
:cmdline" 
(https://list.orgmode.org/orgmode/18f01342a2f.124ad27612732529.8693431365849276...@excalamus.com/),
 behavior like the following was observed in which leading quote marks are 
sometimes removed from results:

#+begin_src bash :results raw
echo \"\"1\"\"
#+end_src

#+RESULTS:
""1""

#+begin_src bash
echo \"\"1\"\"
#+end_src

#+RESULTS:
: 1""

#+begin_src bash :results output
echo \"\"1\"\"
#+end_src

#+RESULTS:
: ""1""

Org mode version 9.7-pre (release_9.6.27-1393-ge0f24a @ 
/home/ahab/Projects/org-mode/lisp/), commit e0f24a3f6

--
Matt Trzcinski
Emacs Org contributor (ob-shell)
Learn more about Org mode at https://orgmode.org
Support Org development at https://liberapay.com/org-mode





Re: columnview dynamic block - different time summing behaviour for EFFORT and CLOCKSUM

2024-04-28 Thread Ihor Radchenko
Alexander Adolf  writes:

> One last question though: I'm developing an add-on package which will
> use the new features. I guess in "Package-Requires:" it should say
> (org "9.7") ?

Yes.

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



Re: FAILED test-ob-shell/bash-uses-assoc-arrays

2024-04-28 Thread Ihor Radchenko
Max Nikulin  writes:

> My guess is that GPLv2 BASH on macOS does not support associative
> arrays. Perhaps these tests should be skipped if BASH_VERSION is not
> fresh enough (not supplied by Apple).
>> 
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e4ab416fc
>
> Feature detection should be more reliable.
>
> ;; Old GPLv2 BASH in macOSX does not support associative arrays.
> (if-let ((bash (executable-find "bash")))
>  (eq 0 (process-file
>  bash nil nil nil
>  "-c" "declare -A assoc_array")))
>
> Even version check may be performed by shell
>
> (if-let ((bash (executable-find "bash")))
>  (eq 0 (process-file
>  bash nil nil nil
>  "-c" "[ ${BASH_VERSINFO[0]} -ge 4 ]")))

Feel free to submit a patch.
It is a marginal improvement I will be happy to merge, if a patch is
provided.

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



Re: HowTo: Upgrade org-mode installation from the command-line

2024-04-28 Thread Ihor Radchenko
"Cook, Malcolm"  writes:

> The section on org-mode 
> [[https://orgmode.org/org.html#Installation][Installation]] entitled "Using 
> Emacs packaging
> system" might be improved with the following advice:

Thanks!

> Note: For the upgraded version to be loaded by emacs, you mush place
> `package-initialize` early in your init.el.  Failure to do so will
> result in the old system version to be loaded, as can be seen:

This is only true when running emacs -Q or emacs -q.
For normal emacs invocation, since Emacs 27, by default, Emacs calls
(package-initialize) automatically on startup.

> Note further that if the above upgrade command was done in an emacs
> shell buffer, you will need to restart emacs to pick up the updated
> package.  Failing to do so will result in `meta-x org-version`
> reporting the old version:
>
> #+begin_src src
> Org mode version 9.6.15 (release_9.6.15 @ 
> /usr/local/share/emacs/30.0.50/lisp/org/)
> #+end_src
>
> but after restart with my init.el file it reports:
>
> #+begin_src src
> Org mode version 9.6.27 ( @ 
> /home/mec/.dotfiles/emacs/.emacs.d/elpa/org-9.6.27/)
> #+end_src

Examples are probably a bit too much for the manual.
It should be sufficient to ask to restart existing Emacs sessions, if
any.

May you prepare a patch modifying doc/org-manual.org with your suggestions?
See https://orgmode.org/worg/org-contribute.html

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



Re: [FR] org-clock-modify-effort-estimate as autoload

2024-04-28 Thread Ihor Radchenko
Jason Hemann  writes:

> Presently, org-clock-modify-effort-estimate is not autoloaded. I imagine that 
> org currently suggests/favors workflow would be that you’d clock in, or 
> interact with org-clock some other way, and only then modify your effort 
> estimates.
>
> I found myself wanting to modify a prior effort estimates when not clocked 
> and before the org-clock file had been loaded. This then made me think 
> org-clock-modify-effort-estimate should be autoloaded, and the function act 
> like another entry point.

Done, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=36a9f6f18

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



Re: [PATCH] org-ctags.el: Protect shell specials in directory name

2024-04-28 Thread Ihor Radchenko
Max Nikulin  writes:

>>> The committed change is anyway incomplete.
>> 
>> May you submit a patch?

> See the attachments.

Thanks!
I tried to run make test with your patch applied, but I am getting
interactive prompt there:

Visit tags table (default TAGS): 

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



Re: link can not be created in a line with another link.

2024-04-28 Thread Ihor Radchenko
Alexandros Prekates  writes:

> In  the example below i  underline to show that a link has been created.
>
> Given that lines :
>
>  [[sysadmInstallSoftware a [[deb][deb package]]
>  [[sysadmInstallSoftware adeb package 
>   ---
>  If i try to complete the left link with:
>  [[sysadmInstallSoftware][Install]]
> /\
> |
>  the moment i insert that left bracket i will get:
>  a [[deb][deb package
>  
>
> If i try that into a line with no other links it will work ok.

Thanks for reporting, but I do not fully understand what you did.
May you please explain step by step, starting from emacs -Q, what you
did, what you saw, and what you expected to see?

Please list what exactly you input into the buffer, and which
keys/commands you use.

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



Re: Cant expand a heading with tab : Subtree (no children)

2024-04-28 Thread Ihor Radchenko
Alexandros Prekates  writes:

> Emacs: 29.1
>
> It happens daily , not initially , but after some hour(s) of using an
> org file to try to expand a heading ,that i know that it has subheadings
> , and it wont expand and see in the echo area the message : SUBTREE (NO
> CHILDREN).

Please try

(1) (setq org-fold-core-style 'overlays) early in your init
(2) Use the latest development version of Org mode.

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



Re: [PATCH] ob-lua: Support all types and multiple values in results

2024-04-28 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> ...
> We need *better tests*, otherwise all this is kind of useless.
>
> I will hack on this some more...

Will you be willing to provide some?

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



Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline

2024-04-28 Thread Ihor Radchenko
Max Nikulin  writes:

>> I conclude that your concern, while being valid, is a _different_ bug.
>> Thus, I do not see it as a blocker for my patch - my patch will fix the
>> *original bug reported on top of this thread*.
>
> My concern is that your patch trying to fix one bug (I am not convinced 
> it is an improvement despite it is a step toward consistency) introduces 
> another one that is not currently present in the code.

May you explain which bug you are referring to?

The bug with bash -c ./script-with-no-shebang described in
https://superuser.com/questions/502984/writing-shell-scripts-that-will-run-on-any-shell-using-multiple-shebang-lines
is already present, and my patch does not change anything about it.

>> (with-temp-file script-file
>>  (if shebang (insert shebang "\n")
>>(insert "#!" shell-file-name "\n"))
>>  (when padline (insert "\n"))
>>  (insert body))
>
> This code has an issue. Interpretation of relative file names in 
> shebangs varies across shells.

May you elaborate? Are you concerned that `shell-file-name' may not be
an absolute path?

> If you insist on parsing :cmdline by shell (I do not like it) then you 
> may try
>
>   ' 
>  '

May you explain how it is better?

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



Re: [BUG] oddity tangling src_blk with :var [9.7-pre (release_9.6.26-1368-g1ae978 @ /home/minshall/.emacs.d/straight/build/org/)]

2024-04-28 Thread Ihor Radchenko
Greg Minshall  writes:

>   here is the variable to be included.
>   ,#+name: variable
>   | 2.4 |
>
>   and, the code block that includes that variable
>   ,#+begin_src sh :var variable=variable :shebang #!/bin/sh :tangle 
> variable.sh
> echo "${variable}"
>   ,#+end_src

Confirmed.

This is because Org mode currently cannot distinguish between babel
backends that simply do not support variable assignments and babel
backends that are not loaded.

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



Re: help: org-mode menu presence mysteriously disappearing and reappearing when I navigate the document

2024-04-28 Thread Ihor Radchenko
"Cook, Malcolm"  writes:

> I have a org document that, when I navigate through it, the org-mode menu 
> disappears and reappears.
> ...
> polymode

This.
Major mode menu is displayed only when the major mode is active, but
polymode will switch the major mode depending on the point location in
the buffer. Most likely, you see the menu disappearing when moving
inside src blocks where polymode activates another major mode.

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



Re: Trailing whitespace after export snippets without a transcoder

2024-04-28 Thread Ihor Radchenko
Max Nikulin  writes:

> On 23/04/2024 02:01, Ihor Radchenko wrote:
>> For example, consider an HTML exporter that aligns tags nicely and
>> keeps blank lines between markup blocks for readability.  If we
>> remove such blank lines unconditionally, it will be problematic.
>
> I consider that just newlines are enough to make HTML markup human 
> readable. I believe blank lines appear in HTML due to conditional 
> constructs interpreted by various template engines and almost nobody 
> cares concerning actual formatting in such cases.

I looked further, and it turns out that Org export is already overriding
the blank lines produced by the exporters.

In particular, we have

((memq type '(nil org-data plain-text raw)) results)
;; Append the same white space between elements or objects
;; as in the original buffer, and call appropriate filters.
(t
 (org-export-filter-apply-functions
  (plist-get info (intern (format ":filter-%s" type)))
  (let ((blank (or (org-element-post-blank data) 0)))
(if (eq (org-element-class data parent) 'object)
(concat results (make-string blank ?\s))
  (concat (org-element-normalize-string results)
  (make-string blank ?\n
  info))

For now, we only override newlines between elements, not objects.
For objects (but not plain-text), we unconditionally append :post-blank.

I conclude that it is actually OK to go a step further and cleanup
newlines after objects, before appending the post-blank.

Same for plain-text.

>> I guess that I can change the condition to not include trailing space
>> from (rx whitespace eol) to (rx (any " \t|) eol).
>
> One more time I forgot that neither \n nor non-breakable space are 
> included into post-blank.

> I think, more permissive regexp may be used. At least it should accept 
> newlines and any space after it
>
>  (rx (any " \t" eol) (zero-or-more whitespace) eos)

I see how special case for \n is useful. Not should about non-breakable
space.

> Moreover, post-blank of the pruned object may be ignored when the 
> following element starts with spaces other than purely zero width ones.

This can never happen, AFAIK.
All the spaces after any object become a part of its :post-blank
attribute.

> My feeling is that extensive test suite is required. It would be easier 
> to review what cases are not handled yet.

May you summarize various examples that should be considered?

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



Re: [BUG] HTML export does not preserve footnote label [9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)]

2024-04-28 Thread Ihor Radchenko
Protesilaos Stavrou  writes:

> Since we are now using labels for the HTML export, I think it makes
> sense to optionally use those for the anchor tags as well.
>
> See the attached patch for a possible way of doing this.
>
> As always, you are welcome to make any further changes.

We can indeed add such option, but is it of any practical use?
Do you have examples of workflows when such new option will be useful?

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



Re: [BUG] HTML export does not preserve footnote label [9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)]

2024-04-28 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Protesilaos Stavrou  writes:
>
>> With regard to the disambiguation scheme, I am playing around with
>> various scenaria to see how Org HTML export behaves. Using the
>> following:
>> ...
>> This is test 2 > role="doc-backlink">1
>> ...
>> This is test 3 > role="doc-backlink">1
>>
>> Notice that the 100 in the ID is not incremented further. I guess this
>> is something that can be worked on but, again, I think it is separate
>> from the issue of using the label for the ID and HREF.
>>
>> Any thoughts?
>
> Duplicate IDs are against HTML spec:
> https://softwareengineering.stackexchange.com/questions/127178/two-html-elements-with-same-id-attribute-how-bad-is-it-really
>
> So, this is a bug.

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e0f24a3f6

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



Re: [BUG] HTML export does not preserve footnote label [9.6.15 (release_9.6.15 @ /usr/local/share/emacs/30.0.50/lisp/org/)]

2024-04-28 Thread Ihor Radchenko
Protesilaos Stavrou  writes:

>> See the attached tentative patch.
>
>> [... 144 lines elided]
>
> Thank you! I just tried it. I encountered two problems with it, which I
> am addressing with the two attached patches (feel free to modify as
> needed). In short:
>
> 1. The footnote definitions at the bottom of the file were still using
> the ordinal HTML id, which did not correspond to the href with the
> label.
>
> 2. If the file had a mixture of labeled and anonymous/unlabeled
> footnotes, then the export would break as it would be passing a nil
> value to 'string-to-number'.
>
> Please let me know how to proceed.

Applied, onto main, after squashing the patches together.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=065af4b42
Handled.

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



[PATCH] org-ctags.el: Protect shell specials in directory name

2024-04-28 Thread Max Nikulin

On 20/03/2024 19:08, Ihor Radchenko wrote:

Max Nikulin writes:

The committed change is anyway incomplete.


May you submit a patch?


See the attachments.From 067dc590bb1c26c881f14d218da2cd502413ec5d Mon Sep 17 00:00:00 2001
From: Max Nikulin 
Date: Wed, 27 Mar 2024 23:04:07 +0700
Subject: [PATCH 1/2] org-ctags.el: Protect shell specials in directory name

* lisp/org-ctags.el (org-ctags-create-tags): Escape shell specials.

Directory name (the argument or `default-directory') may contain various
characters interpreted by shell.  Effects may vary from just incorrect
actual path to execution of a command embedded into path.  Neither
double nor single quotes is a safe way to use directory name in shell
commands since the name may contain these characters.

A follow-up to
Martin Marshall. [PATCH] `org-ctags-create-tags` creates empty TAGS file.
Fri, 09 Feb 2024 18:57:48 -0500.

---
 lisp/org-ctags.el | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lisp/org-ctags.el b/lisp/org-ctags.el
index 6431a2765..52b21dbd1 100644
--- a/lisp/org-ctags.el
+++ b/lisp/org-ctags.el
@@ -477,18 +477,21 @@ (defun org-ctags-create-tags ( directory-name)
 its subdirectories contain large numbers of taggable files."
   (interactive)
   (cl-assert (buffer-file-name))
-  (let ((dir-name (or directory-name
-  (file-name-directory (buffer-file-name
+  (let ((dir-name (shell-quote-argument
+   (expand-file-name
+(if directory-name
+(file-name-as-directory directory-name)
+  (file-name-directory (buffer-file-name))
 (exitcode nil))
 (save-excursion
   (setq exitcode
 (shell-command
  (format (concat "%s --langdef=orgmode --langmap=orgmode:.org "
- "--regex-orgmode=\"%s\" -f \"%s\" -e -R %s")
+ "--regex-orgmode=%s -f %sTAGS -e -R %s*")
  org-ctags-path-to-ctags
- org-ctags-tag-regexp
- (expand-file-name (concat dir-name "/TAGS"))
- (expand-file-name (concat (shell-quote-argument dir-name) "/*")
+ (shell-quote-argument org-ctags-tag-regexp)
+ dir-name
+ dir-name)))
   (cond
((eql 0 exitcode)
 (setq-local org-ctags-tag-list
-- 
2.39.2

From 52611183ff73d0701d41102e0fa97134178cae10 Mon Sep 17 00:00:00 2001
From: Max Nikulin 
Date: Sun, 28 Apr 2024 14:13:04 +0700
Subject: [PATCH 2/2] test-org-ctags.el: Test escaping of shell arguments

* testing/lisp/test-org-ctags.el (test-org-ctags/create-tags-escape):
A new test that tag regexp and directory names are properly quoted
while "*" wildcard is active.
(test-org-ctags/list-elements test-org-ctags/list-elements-equal-p)
(test-org-ctags/list-elements-equal-explain): Helpers to provide
informative failure messages.
(test-org-ctags/with-fake-ctags): A helper to create temporary
directories and a file and to temporary arrange a mock shell command
instead of ctags executable.
(test-org-ctags/mock-command test-org-ctags/get-args): Helpers to define
a mock shell command and to obtain its actual arguments.
---
 testing/lisp/test-org-ctags.el | 192 +
 1 file changed, 192 insertions(+)
 create mode 100644 testing/lisp/test-org-ctags.el

diff --git a/testing/lisp/test-org-ctags.el b/testing/lisp/test-org-ctags.el
new file mode 100644
index 0..7f5fca948
--- /dev/null
+++ b/testing/lisp/test-org-ctags.el
@@ -0,0 +1,192 @@
+;;; test-org-ctags.el --- tests for org-ctags.el  -*- lexical-binding: t -*-
+
+;; Copyright (C) 2024 Max Nikulin
+;; Authors: Max Nikulin
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see .
+
+;;; Code:
+
+;; Alternative implementation for `test-org-ctags/mock-command'
+;; is required for cmd.exe.
+(unless (string-equal "-c" shell-command-switch)
+  (signal 'missing-test-dependency "POSIX shell"))
+
+(require 'org-ctags)
+
+ Helpers:
+
+(defun test-org-ctags/mock-command (temp-file command-name)
+  "Define shell function COMMAND-NAME wrining arguments to TEMP-FILE."
+  ;; Failure exit code is used to prevent further `org-ctags' actions.
+  (format "%s() 

link can not be created in a line with another link.

2024-04-28 Thread Alexandros Prekates


Emacs  : GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.16.0) of 2023-09-11, modified by Debian
Package: Org mode version 9.6.6 (release_9.6.6 @
/usr/share/emacs/29.1/lisp/org/)


In  the example below i  underline to show that a link has been created.

Given that lines :

 [[sysadmInstallSoftware a [[deb][deb package]]
 [[sysadmInstallSoftware adeb package 
  ---
 If i try to complete the left link with:
 [[sysadmInstallSoftware][Install]]
/\
|
 the moment i insert that left bracket i will get:
 a [[deb][deb package
 

If i try that into a line with no other links it will work ok.