Re: [PATCH v2] Show org file title in org-clock clocktable

2022-08-17 Thread Ihor Radchenko
Duy Nguyen  writes:

> Thank you once again for your comments Ihor. Please find attached a new
> patch with your comments addressed.

Thanks!

> +(let ((macros (org-macro--collect-macros)))
> +  (let ((title (assoc-default "title" macros)))

It is not a good idea to call internal function (with "--" in name) from
a different file. Such functions are a subject of change without notice.

`org-macro-templates' is always initialized when Org mode is active, and
you can rely on its value.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Re: [BUG] org-auto-repeat-maybe: error "Can’t expand minibuffer to full frame" and missing log note

2022-08-17 Thread Ihor Radchenko
Bhavin Gandhi  writes:

>> Thanks! I received the PDF to sign the next day after my email, this
>> will probably take a couple of days more from my side as I'm talking
>> with my employer.
>
> I finally got this done. I now have a fully executed copy of the copyright
> assignment (signed by FSF and me). Do I need to send it to someone so
> that they can check and update the page at
> https://orgmode.org/worg/contributors.html ?

You do not need to share the paperwork with us. FSF has a database
available to GNU maintainers with a list of all the people with
copyright assignment.

I am CCing Bastien.
Bastien, can you please confirm that Bhavin's paperwork is registered
and add him to the contributor list?

>> Yikes! Then, can also check for window-minibuffer-p, but I feel that it
>> will be a fight against all kinds of edge cases.
>
> I haven't been able to make much progress on this bug in the last two
> weeks. Will try to send a patch in a few days, as the steps I gave above
> feels like an edge case which we won't see happening hopefully.

Your patch will be already an improvement.

I guess that the proper fix of this type of issues would be rewriting
the note system in such a way that it uses recursive editing. Then, we
can make the user write the note in the middle of a running command and
not worry about post-command-hook quirks. But that will be a much more
involved change.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Re: [BUG] Incorrect fontification of src blocks for indentation sensitive language modes

2022-08-17 Thread Ihor Radchenko
Bhavin Gandhi  writes:

> In the following Org mode file, the Ledger mode source block is not
> highlighted correctly.
>
> How to reproduce:
> ...

Confirmed.
Another example is
https://www.reddit.com/r/orgmode/comments/wi0jq9/highlight_doesnt_work_for_src_block_of_diff_with/

> PS: I haven't looked at the code of org-src-font-lock-fontify-block in
> detail, so I could be wrong with this analysis.

`org-src-font-lock-fontify-block' is indeed the culprit. It copies the
text between begin/end markers verbatim without adjusting the
indentation. The proper way would be using an approach similar to
`org-edit-src-code', but it may be tricky to map the fontification back
into the original block without a need to delete/re-insert the code into
Org buffer. Editing during fontification is a bad idea, so some kind of
smarter approach should be used in order to fix this.

P.S. I am genuinely surprised that this bug is only revealed now.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



Show a warning/message when loading Org modules requiring external packages (was: :session for Julia in org babel?)

2022-08-17 Thread Ihor Radchenko
"Christopher M. Miles"  writes:

> What about write a elisp function to automatic the installation of those
> required two Julia packages? If not, at least raise a warning for user
> to install those two packages after detection not exist. WDYT?

Installation is not a good idea because there are multiple alternative
package managers in Emacs. Some of them explicitly require user to add
code into init.el (I am referring to straight.el).

However, we may, indeed, show some helpful warning/message.

A reasonable place to implement such message is org-load-modules-maybe.
It might catch the relevant errors and show the message.

Patches are welcome!

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



[BUG] org-insert-heading-respect-content doesn't always insert TODO heading [9.5.4 (release_9.5.4-17-g6e991f @ /usr/local/Cellar/emacs-plus@29/29.0.50/share/emacs/29.0.50/lisp/org/)]

2022-08-17 Thread Roman Rudakov
Hello!

Steps to reproduce:
1. Create an org heading and set state to something but TODO or DONE
(for example PROGRESS).
2. Call the function org-insert-todo-heading-respect-content

Expected result:

New heading with TODO state in inserted

Actual result:

New heading is inserted with the same state as previous heading.

I noticed that internally this function calls org-insert-todo-heading
and pass arguments in a wrong order:

Actual function call:

(org-insert-todo-heading force-state '(4))

Should be:

(org-insert-todo-heading '(4)) force-state)


Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin21.6.0, NS
appkit-2113.60 Version 12.5 (Build 21G72))
 of 2022-08-14
Package: Org mode version 9.5.4 (release_9.5.4-17-g6e991f @
/usr/local/Cellar/emacs-plus@29/29.0.50/share/emacs/29.0.50/lisp/org/)




Re: :session for Julia in org babel?

2022-08-17 Thread Timothy
Hi Eric and Ihor,

The ob-julia code is in need of an overhaul, and it’s on my todo list but I have
no idea when I’ll get to it. In the meantime, I think
 (which Eric, I think you’ve tried?) should
be better to use.

All the best,
Timothy


Re: [BUG] Incorrect fontification of src blocks for indentation sensitive language modes

2022-08-17 Thread Fraga, Eric
On Wednesday, 17 Aug 2022 at 17:39, Ihor Radchenko wrote:
> P.S. I am genuinely surprised that this bug is only revealed now.

I'm not.  Is there any other language whose fontification is indentation
dependent?  Python is indentation based but the fontification doesn't
get affected (generally speaking) as it's keyword based.

-- 
: Eric S Fraga, with org release_9.5.4-737-gd3a9c4 in Emacs 29.0.50


Re: Show a warning/message when loading Org modules requiring external packages

2022-08-17 Thread Fraga, Eric
On Wednesday, 17 Aug 2022 at 17:51, Ihor Radchenko wrote:
> "Christopher M. Miles"  writes:
>> What about write a elisp function to automatic the installation of those
>> required two Julia packages? If not, at least raise a warning for user
>> to install those two packages after detection not exist. WDYT?
>
> Installation is not a good idea because there are multiple alternative
> package managers in Emacs. Some of them explicitly require user to add
> code into init.el (I am referring to straight.el).

And more importantly in this case, it is not Emacs that would be
affected but the Julia configuration.  Julia has an interesting package
system but not one that I would want Emacs to manipulate behind the
scenes.

-- 
: Eric S Fraga, with org release_9.5.4-737-gd3a9c4 in Emacs 29.0.50


Re: :session for Julia in org babel?

2022-08-17 Thread Fraga, Eric
On Wednesday, 17 Aug 2022 at 18:16, Timothy wrote:
> The ob-julia code is in need of an overhaul, and it’s on my todo list
> but I have no idea when I’ll get to it. 

Stephen Eglen has suggested the same and also that maybe a few of us get
"together" to discuss what is needed etc.  I have copied Stephen in.

> In the meantime, I think  (which
> Eric, I think you’ve tried?) should be better to use.

I have indeed tried it.  It is better in some (many) respects but also
has some subtly different outcomes which affect my particular use case
as part of a large book writing project where I don't need any surprises
at this stage ;-).  Once I'm finished with the book (soon -- famous last
words), I can consider switching over.

-- 
: Eric S Fraga, with org release_9.5.4-737-gd3a9c4 in Emacs 29.0.50

Re: [PATCH v3] Show org file title in org-clock clocktable

2022-08-17 Thread Duy Nguyen
>
> It is not a good idea to call internal function (with "--" in name) from
> a different file. Such functions are a subject of change without notice.
>
> `org-macro-templates' is always initialized when Org mode is active, and
> you can rely on its value.
>

Thanks for letting me know. The reason I chose that method is because the
org-macro-templates are not updated immediately after I change the title
and save the file. However, I think I found a solution using
org-macro-initialize-templates and org-macro-templates. Please see the
attached patch. Hope this is OK, otherwise please let me know how to
improve.

Duy
From f4a320a8aded88d0af3fb8202b64ea7e99ccb10b Mon Sep 17 00:00:00 2001
From: Duy Nguyen 
Date: Fri, 12 Aug 2022 18:40:10 +0200
Subject: [PATCH v3] lisp/org-clock.el: Show file title in org-clock clocktable

* lisp/org-clock.el (org-clocktable-defaults): Add default value for
new clock table option `:filetitle'.
(org-clock-get-file-title): Add new function to extract title of org file.
(org-clocktable-write-default): Print org file name in clock table if
`:filetitle' is set to `t'.

* doc/org-manual.org (The clock table): Include new `:filetitle'
option in manual for clock table.

* etc/ORG-NEWS (New =:filetitle= option for clock table): Include new
`:filetitle' option for clock table.

Allow user to show org file title instead of file name in the
clock table.  If the file does not have a title defined, the file name
will be shown in the clock table.

TINYCHANGE
---
 doc/org-manual.org |  4 
 etc/ORG-NEWS   | 13 +
 lisp/org-clock.el  | 17 -
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 1effed6c4..daee03401 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -6800,6 +6800,10 @@ using the =:formatter= parameter.
 
   Indent each headline field according to its level.
 
+- =:filetitle= ::
+
+  Show title in the file column if the file has a =#+title=.
+ 
 - =:hidefiles= ::
 
   Hide the file column when multiple files are used to produce the
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 00fe101dc..eefe4adc2 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -270,6 +270,19 @@ example,
 
 prints a sub-bibliography containing the book entries with =ai= among
 their keywords.
+*** New =:filetitle= option for clock table
+
+The =:filetitle= option for clock tables can be set to ~t~ to show org
+file title (set by =#+title:=) in the File column instead of the
+file name. For example:
+
+#+begin_src org
+,#+BEGIN: clocktable :scope agenda :maxlevel 2 :block thisweek :filetitle t
+#+end_src
+
+If a file does not have a title, the table will show the file name
+instead.
+
 ** New options
 *** A new custom setting =org-hide-drawer-startup= to control initial folding state of drawers
 
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 362abe358..4f4f4b607 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -324,6 +324,7 @@ string as argument."
:link nil
:narrow '40!
:indent t
+   :filetitle nil
:hidefiles nil
:formula nil
:timestamp nil
@@ -2469,6 +2470,17 @@ the currently selected interval size."
 	  (org-update-dblock)
 	  t)
 
+;;;###autoload
+(defun org-clock-get-file-title (file-name)
+  "Get the file title from FILE-NAME as a string. Returns short
+FILE-NAME if title is not found."
+  (with-current-buffer (find-file-noselect file-name)
+(org-macro-initialize-templates)
+(let ((title (assoc-default "title" org-macro-templates)))
+  (if (null title)
+  (file-name-nondirectory file-name)
+title
+
 ;;;###autoload
 (defun org-dblock-write:clocktable (params)
   "Write the standard clocktable."
@@ -2584,6 +2596,7 @@ from the dynamic block definition."
 	 (emph (plist-get params :emphasize))
 	 (compact? (plist-get params :compact))
 	 (narrow (or (plist-get params :narrow) (and compact? '40!)))
+	 (filetitle (plist-get params :filetitle))
 	 (level? (and (not compact?) (plist-get params :level)))
 	 (timestamp (plist-get params :timestamp))
 	 (tags (plist-get params :tags))
@@ -2723,7 +2736,9 @@ from the dynamic block definition."
 			 (if (eq formula '%) " %s |" "")
 			 "\n")
 
-		 (file-name-nondirectory file-name)
+ (if filetitle
+ (org-clock-get-file-title file-name)
+   (file-name-nondirectory file-name))
 		 (if level?"| " "") ;level column, maybe
 		 (if timestamp "| " "") ;timestamp column, maybe
 		 (if tags  "| " "") ;tags column, maybe
-- 
2.32.1 (Apple Git-133)



Re: Show a warning/message when loading Org modules requiring external packages (was: :session for Julia in org babel?)

2022-08-17 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> What about write a elisp function to automatic the installation of those
>> required two Julia packages? If not, at least raise a warning for user
>> to install those two packages after detection not exist. WDYT?
>
> Installation is not a good idea because there are multiple alternative
> package managers in Emacs. Some of them explicitly require user to add
> code into init.el (I am referring to straight.el).
>
> However, we may, indeed, show some helpful warning/message.
>
> A reasonable place to implement such message is org-load-modules-maybe.
> It might catch the relevant errors and show the message.

I found ~org-load-modules-maybe~ load modules from ~org-modules~, it's a
list of ob-* or ol-* elisp modules. Not Julia modules. I searched
~org-load-modules-maybe~ function invocation code in org-mode source
code, have not relative examples. Don't know how to use
~org-load-modules-maybe~ to detect whether Julia modules exist and raise
helpful warning message.

>
> Patches are welcome!


-- 

[ stardiviner ]
I try to make every word tell the meaning that I want to express without 
misunderstanding.

Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


signature.asc
Description: PGP signature