Re: [PATCH] Re: what is the purpose of "This link has already been stored"?

2023-07-20 Thread Samuel Wales
On 7/15/23, Ihor Radchenko  wrote:
> Applied, onto main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c0dbcf361

thank you!  will this reach bugfix too?

-- 
The Kafka Pandemic

A blog about science, health, human rights, and misopathy:
https://thekafkapandemic.blogspot.com



Re: [BUG] [PATCH] Avoid interaction in test ~ob-tangle/detangle-false-positive~

2023-07-20 Thread Evgenii Klimov


Ihor Radchenko  writes:

> Evgenii Klimov  writes:
>
>> Test ~ob-tangle/detangle-false-positive~ asks for confirmation to kill
>> the buffer, connected to testing/examples/babel.org file, that is
>> modified during the couse of the test.
>>
>> Way to reproduce the bug (from projects main dir):
>
> Thanks!
> Waiting for your copyright assignment before applying.

Copyright assignment is complete.



Re: Unable to unfold a folded block having point directly after the folded block

2023-07-20 Thread Evgenii Klimov


Hi

Vlastimil Vondra  writes:

> Perfect, org-reveal is working as well, haven't known about that! But it 
> would be good that org-reveal is called automatically before org-cycle, 
> because when
> going through the task list, I'm just expanding by tab. It is not really 
> convenient to use tab and when reaching error (or no unfold) then hitting C-c 
> C-r.
> Maybe it's just me.
[...]

Can't you move the point at the beginning of the line before starting to
expand by tab? That way =org-speed-commands= will be available for you
and moving/expanding will be even faster.



Re: [BUG] SPACE jumps to tag in header line after hidden emphasis marker [9.7-pre (release_9.6.7-562-g5b6268 @ /home/jschmidt/work/org-mode/lisp/)]

2023-07-20 Thread Jens Schmidt

On 2023-07-18  10:13, Ihor Radchenko wrote:


No, it is space. In particular, it is `org--align-tags-here' + some bug
in Emacs that screws up column computation.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64696


FWIW the third test yields

 ■  Warning (emacs): Test #3:: ’word’ is hidden applying ’invisible 
text property to heading body.

 ■  Warning (emacs): Moved point after first ’word’
 ■  Warning (emacs): 1:: current-column = 0
 ■  Warning (emacs): redisplayed
 ■  Warning (emacs): 2:: current-column = 0
 ■  Warning (emacs): Indented to column 50
 ■  Warning (emacs): 3:: current-column = 0
 ■  Warning (emacs): redisplayed
 ■  Warning (emacs): 4:: current-column = 0
 ■  Warning (emacs): Enabled visible mode
 ■  Warning (emacs): 5:: current-column = 50
 ■  Warning (emacs): redisplayed
 ■  Warning (emacs): 6:: current-column = 50

on my system which seems to be different from what you described.

And for the fun of it: With (indent-tabs-mode -1) tests 3 and 4 report 
column 54 for "5::" and "6::".





Re: org-bibtex manual

2023-07-20 Thread Ypo
No, I mean customizing the generated headline. Instead of just title, to 
be like:


* Author (year) /Title/. Publisher

Bests

El 20/07/2023 a las 21:00, Ihor Radchenko escribió:

Ypo  writes:


Then, is it not possible to customize the entry generated with
org-bibtex-create?

You mean fields?
Everything is defined in `org-bibtex-types', but it is not currently a 
defcustom.

I see no problem adding user types.


Re: org-bibtex manual

2023-07-20 Thread Ihor Radchenko
Ypo  writes:

> Then, is it not possible to customize the entry generated with 
> org-bibtex-create?

You mean fields?
Everything is defined in `org-bibtex-types', but it is not currently a 
defcustom.

I see no problem adding user types.

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



Re: org-bibtex manual

2023-07-20 Thread Ypo

Hi Ihor.

Then, is it not possible to customize the entry generated with 
org-bibtex-create?


Bests



>/#+begin_src emacs-lisp/
>/(defun my-org-bibtex-headline-format (entry)/
>/  "Custom function to generate the headline text for org-bibtex-write."/
>/  (let* ((title (cdr (assoc :title entry)))/
>/ (author (cdr (assoc :author entry/
>/    (concat "Mi encabezado personalizado: " title " - " author)))/
>
>/(setq org-bibtex-headline-format #'my-org-bibtex-headline-format)/
>/#+end_src/

This is correct, but this customization only works in
`org-bibtex-write', which works together with `org-bibtex-read-buffer' /
`org-bibtex-read-file'.

`org-bibtex-create' hard-codes heading to be the same with BiBTeX :title
field.

Yes, org-bibtex is not very polished.


Re: [BUG] WORG example for ob-lilypond is no longer working as described (was: Moving some lisp/ob-*.el files to org-contrib - your advice?)

2023-07-20 Thread Jonathan Gregory


On 20 Jul 2023, Ihor Radchenko wrote:

With your patch, I cannot produce png output. The file is just 
not created: [...]


You're right. Thanks for the feedback.

I've made some changes and was able to produce the correct results 
using pdf, eps, and png (tested with 2.20.0 and 2.24.1). I think 
this gets us closer to the old behaviour, assuming there are no 
other issues, of course.



--
Jonathan
diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 9693b89e2..8533cd8c7 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -178,28 +178,39 @@ specific arguments to =org-babel-tangle=."
 (defun org-babel-lilypond-process-basic (body params)
   "Execute a lilypond block in basic mode."
   (let* ((out-file (cdr (assq :file params)))
+ (file-type (file-name-extension out-file))
 	 (cmdline (or (cdr (assq :cmdline params))
 		  ""))
 	 (in-file (org-babel-temp-file "lilypond-")))
 
 (with-temp-file in-file
-  (insert (org-babel-expand-body:generic body params)))
+  ;; To create music fragments suitable for mixing music and text,
+  ;; newer versions of lilypond require setting at least the
+  ;; following two variables introduced in version 2.22. See:
+  ;; https://lilypond.org/doc/v2.24/Documentation/usage/other-programs
+  (insert
+   (format "#(if (ly:get-option 'use-paper-size-for-page)
+ (begin (ly:set-option 'use-paper-size-for-page #f)
+(ly:set-option 'tall-page-formats '%s)))\n"
+   file-type)
+   (org-babel-expand-body:generic body params)))
 (org-babel-eval
  (concat
   org-babel-lilypond-ly-command
   " -dbackend=eps "
   "-dno-gs-load-fonts "
   "-dinclude-eps-fonts "
-  (or (cdr (assoc (file-name-extension out-file)
-		  '(("pdf" . "--pdf ")
-			("ps" . "--ps ")
-			("png" . "--png "
+  (or (assoc-default file-type
+ '(("pdf" . "--pdf ")
+			   ("eps" . "--eps ")))
 	  "--png ")
   "--output="
   (file-name-sans-extension out-file)
   " "
   cmdline
-  in-file) "")) nil)
+  in-file)
+ ""))
+  nil)
 
 (defun org-babel-prep-session:lilypond (_session _params)
   "Return an error because LilyPond exporter does not support sessions."


Re: Is there a better (built-in) way to insert an org link with title as description?

2023-07-20 Thread Max Nikulin

On 19/07/2023 19:06, Arthur Miller wrote:

I want to auto insert a title from an HTML page as description for an org link 
in
my notes.
(defun org-link-from-clipboard ()

...

   (url-retrieve url
(lambda (buffer)
  (goto-char (point-min))
  (when (re-search-forward "\\(.*\\)" nil t)


What are origins of your links?

If it is an URL opened in browser then `org-capture' or 
org-protocol:/store-link/ may be used. There are a number of browser 
extensions for that.


More metadata sometimes desired and just page title is not enough. For 
extracting it within Emacs see e.g. Ihor's

https://github.com/yantar92/org-capture-ref
Search for its discussions on this mailing lists.

Some complications:
- titles may have &...; entities
- Not all pages have , so heuristics have to be used.
- Some HTML files contains nothing besides JavaScript to load actual content
- Some URLs are from minifiers or obfuscated by Outlook "protection", 
trampolines to prevent leaking of data through the Referer header, etc. 
Likely redirection target should be saved, not original URL.
- Some sites like GitHub have API that allows to get metadata in JSON 
format. It is better than parsing HTML with regexp.


Anyway I suggest to split non-interactive part of the command to allow 
code reuse (for drag and drop, etc.).




Re: Is there a better (built-in) way to insert an org link with title as description?

2023-07-20 Thread Ihor Radchenko
Arthur Miller  writes:

> I want to auto insert a title from an HTML page as description for an org 
> link in
> my notes. I stumbled upon some old message by Miro Bezjak on this list:
>
> https://lists.gnu.org/archive/html/emacs-orgmode/2012-09/msg01435.html
>
> I have seen the replies, but I am not sure how to use
> org-make-link-description-function

Since that time, Org got a capability to set description function
per link type. Just use

(org-link-set-parameters "http" :insert-description #'your-function)
(org-link-set-parameters "https" :insert-description #'your-function)

The calling convention is the same as
`org-link-make-description-function'.

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



Re: Unable to unfold a folded block having point directly after the folded block

2023-07-20 Thread Vlastimil Vondra
Perfect, org-reveal is working as well, haven't known about that! But it
would be good that org-reveal is called automatically before org-cycle,
because when going through the task list, I'm just expanding by tab. It is
not really convenient to use tab and when reaching error (or no unfold)
then hitting C-c C-r. Maybe it's just me.

Anyway thanks for letting me know.

BR,
Vlastimil

On Thu, 20 Jul 2023 at 11:20, Ihor Radchenko  wrote:

> [ Adding Org mailing list back to CC ]
>
> Vlastimil Vondra  writes:
>
> > Sorry, I think I've sent the reply in wrong manner. I was trying to reply
> > to this conversation https://list.orgmode.org/87ty4b7ofr@gnu.org/t/
> > where Reiner wrote that he is not able to unfold tree if folded and at
> the
> > end of line. You can get there if you are on line longer then previous,
> > then up arrow and now you are not able to unfold. I've created function,
> > which will first set cursor to end-of-line by function and then calling
> > org-cycle which is then working.
>
> You are replying to a thread that is 10 years old. That problem
> discussed in the thread has been fixed in Org 9.4.4 or earlier (for
> drawers).
>
> > I'm sending video, so it is more obvious.
>
> In the video, the situation is with folded headings of different length:
>
> * asd
> alskdj
> * Headingalksjdlaskdj
> alskdj
>
> If everything is folded:
>
> * asd...
> * Headingalksjdlaskdj...
>
> Pressing C-p will yield
>
> * asd... <-- note  after ...
> * Headingalksjdlaskdj...
>
> Then,  will indeed not unfold, before the point is not actually on
> heading.
> This situation is one of the edge cases with point adjustment in Emacs.
>
> The workaround is simple - M-x org-reveal (C-c C-r).
> org-reveal generally works any time the cursor is stuck in the middle of
> invisible text.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


Re: Unable to unfold a folded block having point directly after the folded block

2023-07-20 Thread Ihor Radchenko
[ Adding Org mailing list back to CC ]

Vlastimil Vondra  writes:

> Sorry, I think I've sent the reply in wrong manner. I was trying to reply
> to this conversation https://list.orgmode.org/87ty4b7ofr@gnu.org/t/
> where Reiner wrote that he is not able to unfold tree if folded and at the
> end of line. You can get there if you are on line longer then previous,
> then up arrow and now you are not able to unfold. I've created function,
> which will first set cursor to end-of-line by function and then calling
> org-cycle which is then working.

You are replying to a thread that is 10 years old. That problem
discussed in the thread has been fixed in Org 9.4.4 or earlier (for
drawers).

> I'm sending video, so it is more obvious.

In the video, the situation is with folded headings of different length:

* asd
alskdj
* Headingalksjdlaskdj
alskdj

If everything is folded:

* asd...
* Headingalksjdlaskdj...

Pressing C-p will yield

* asd... <-- note  after ...
* Headingalksjdlaskdj...

Then,  will indeed not unfold, before the point is not actually on
heading.
This situation is one of the edge cases with point adjustment in Emacs.

The workaround is simple - M-x org-reveal (C-c C-r).
org-reveal generally works any time the cursor is stuck in the middle of
invisible text.

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



Re: Unable to unfold a folded block having point directly after the folded block

2023-07-20 Thread Ihor Radchenko
Vlastimil Vondra  writes:

> Unable to unfold a folded block having point directly after the folded block

I tried to reproduce the problem and I cannot.

May you please provide more details?
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 



Re: Unable to unfold a folded block having point directly after the folded block

2023-07-20 Thread Vlastimil Vondra

Hi all,

I solved it by using "(org-end-of-line)" before "(org-cycle)"

(defun my/org-cycle ( arg)
  "adjust org-cycle"
  (interactive "P")
  (org-end-of-line)
  (org-cycle arg)
  )

I hope it could be useful to somebody.

Best regards,

Vlastimil Vondra




Re: [PATCH] org-clock-sum: Rewrite function to improve performance

2023-07-20 Thread Ihor Radchenko
Morgan Smith  writes:

> I have a very big file with lots of clock entries and refreshing my clocktable
> has become slow.  Using '(benchmark-elapse (org-ctrl-c-ctrl-c))' I saw that it
> took 5.660532903 seconds to refresh it!  After this rewrite it only takes
> 3.384914703 seconds.  Not great, but better.

Thanks, but the approach you used is questionable.
You are forcing Org to parse the whole buffer as opposed to the existing
approach with parsing only the necessary parts.

While I do see how your implementation might be faster for certain Org
files (many clock entries, little other elements), but I do not see how
it can be faster in general case.

May you instead share the benchmark data for the original Org's code on
your file?

1. M-x profiler-start  cpu 
2. Generate the clock table
3. M-x profiler-report 
4. M-x profiler-report-write-profile
5. Share the saved profile file

P.S.

I did a benchmark on another large buffer and with the existing
implementation I am getting (first column is time in ms):

   15989  58%  - org-clock-sum
   15837  58%   - 
org-element-at-point
   15517  56%+ 
org-element--parse-to

With your code

   27347  87%   - org-clock-sum
   27347  87%- let*
   27347  87% - unwind-protect
   27347  87%  - progn
   27347  87%   - let*
   27310  87%- org-element-map
   27230  87% + 
org-element-parse-buffer

and the code is not yet even done, stopping processing due to error.

Further, you dropped the

 ((match-end 4)
  ;; A naked time.

branch of the code, which accounts for CLOCK: => HH:MM lines that are not clock 
elements.

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



Re: [BUG] WORG example for ob-lilypond is no longer working as described (was: Moving some lisp/ob-*.el files to org-contrib - your advice?)

2023-07-20 Thread Ihor Radchenko
Jonathan Gregory  writes:

>> I do not mind. But remember that we are talking just about an 
>> example file. What you are suggesting appears to be closer to 
>> what we might do in ob-lilypond itself, when calculating default 
>> layout.
>
> That would be even better, I agree.
>
> Can you test my patch?

With your patch, I cannot produce png output. The file is just not
created:

#+begin_src lilypond :file ionian.png
\relative c' {
  c d e f
  g a b c
  b a g f
  e d c d
  e f g a
  b c b a
  g f e d
  c1
}
#+end_src

> Command-line options are normally added to 
> `org-babel-lilypond-ly-command`, but since we're trying to set 
> variables conditionally to accommodate different versions, I don't 
> see how we can do this without using scheme. WDYT?

Your approach seems fine.
It is not uncommon for babel backends to add extra code to the src block body.

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