[PATCH v3.2] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2024-07-17 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> I think that instead of changing the existing function, we can convert
>>> your patch into a new function `org-toggle-inline-images-command' that
>>> will be free to alter the argument order. We can then re-bind that
>>> function in org-keys to make it used by default, but only interactively.
>>>
>> I don't think so, the patch main purpose is for improve image refreshing
>> after babel result image displaying. Because the function is hooked by
>> other ob-* packages. Another purpose is headline level images displaying.
>> So modifying this function is the only way.
>
> Fair point.
> Then, for backward compatibility, we may treat any non-nil, non-list
> (like '(4), '(16), '(64)), non-number (like 1, 11) value as
> INCLUDE-LINKED. This way, the existing calls like
> (org-toggle-inline-images t) will not be broken.
>
> Also, the signature should be
>
> (defun org-toggle-inline-images ( arg beg end include-linked)
>
> So that the meaning of the second and third argument is unchanged.
>

I prefer this compromise result.
I updated the patch, Please review it whether it's correct.

>>> As for displaying linked images, what about something like
>>>
>>>
>>> C-1 C-c C-x C-v being equivalent of
>>> C-c C-x C-v + INCLUDE-LINKED=t
>>> (display in current section/region, with linked)
>>>
>>> and
>>>
>>> C-11 C-c C-x C-v being equivalent of
>>> C-u C-u C-c C-x C-v + INCLUDE-LINKED=t
>>> (display in the whole buffer, with linked)
>>>
>> Don't know, I have not use it this way. I think INCLUDE-LINKED is just a
>> option argument for function org-display-inline-images. No need to be
>> available for toggle in interactive command. An option like
>> org-inline-images-include-linked is enough.
>
> Sorry, but ignoring backwards compatibility is not an option.
> If you personally haven't used some feature, it does not mean that
> others also didn't.
>
> We can make limited compromises, but should try our best not to break
> things that were working before.
> See https://bzg.fr/en/the-software-maintainers-pledge/
>

I agree with backward compatibility is very important.

I did a source code statistics researching of using the function 
org-toggle-inline-images at two places:

- GitHub: 
https://github.com/search?q=org-toggle-inline-images=opensearch=code=3
(Only package scimax incoke this function with INCLUDE-LINKED argument t)
- My installed Emacs packages, NO package invoke this function with argument 
INCLUDE-LINKED.

So lucky this change will not affect lot.

>>>> +If cursor is on an inline image link, display the inline image.
>>>> +If there is none, remove it otherwise.
>>>
>>> I do not quite understand what the last line is trying to say.
>>
>> Emmm, I forget the meaning of it. I read the docstring again, seems it
>> can be deleted. I will delete it in my patch.
>
>> After yesterday night studying source code, I still can't figure out
>> solution. So I pass this patch to you. Wait you to finish the unfinished
>> part of path.
>
> I hope that now you have enough information to update the patch.
> Let me know if not.

If this patch is still not ok, really hope you can edit my patch.

From a2707a0f92c76188c3ebb412fe2b57788b50ca9a Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Mon, 22 May 2023 16:25:33 +0800
Subject: [PATCH] org: Improve inline images displaying like LaTeX previewing

* lisp/org.el (org-toggle-inline-images): Implement LaTeX previewing
same logic in inline images toggle displaying.
---
 lisp/org-keys.el |  2 +-
 lisp/org.el  | 95 
 2 files changed, 81 insertions(+), 16 deletions(-)

diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index 38fac57d8..7b3b84af4 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -204,7 +204,7 @@
 (declare-function org-toggle-radio-button "org" ( arg))
 (declare-function org-toggle-comment "org" ())
 (declare-function org-toggle-fixed-width "org" ())
-(declare-function org-toggle-inline-images "org" ( include-linked beg end))
+(declare-function org-toggle-inline-images "org" ( arg beg end include-linked))
 (declare-function org-latex-preview "org" ( arg))
 (declare-function org-toggle-narrow-to-subtree "org" ())
 (declare-function org-toggle-ordered-property "org" ())
diff --git a/lisp/org.el b/lisp/org.el
index e72cf056a..c01952b97 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16160,22 +16160,87 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
   (w

Org Babel related popup buffer names not unified

2024-07-13 Thread Christopher M. Miles

I use bellowing config to manage Org Babel related popup buffer displaying.

(add-to-list 'display-buffer-alist '("^\\*Org Src.*\\*" . 
(display-buffer-below-selected)))
(add-to-list 'display-buffer-alist '("^\\*Org Babel Results\\*" . 
(display-buffer-below-selected)))
(add-to-list 'display-buffer-alist '("^\\*Org Babel Preview.*\\*" . 
(display-buffer-below-selected)))
(add-to-list 'display-buffer-alist '("^\\*Org Babel Error Output\\*" . 
(display-buffer-below-selected)))

I found in org-mode source code, some places use "*Org-Babel Results*",
somewhere does not have dash between *Org-Babel, "*Org-Babel Results*".

Other Org Babel related buffer names has same situations.

I hope org-mode can unify those buffer names.

Ihor, WDYT?

-- 

[ 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


[C-c C-q] org-set-tags-command completed tags does not contains current buffer local tags

2024-04-17 Thread Christopher M. Miles

In the [C-c C-q] org-set-tags-command, I found it does not complete tags in 
current buffer.

#+begin_src emacs-lisp
(defun org-set-tags-command ( arg)
  ...
  (let* (...
 (local-table (or org-current-tag-alist (org-get-buffer-tags)))
 ;; the `org-current-tag-alist' is from my customized 
`org-tag-persistent-alist'.
 ...)))
#+end_src

Steps to reproduce:

1. create an empty Org mode file and open it as a Emacs buffer.
2. Fill in Org content as bellowing

#+begin_src org
* headline 1  :tag1:workflow:

* headline 2 :tag2:name:
#+end_src

3. save buffer
4. Press [C-c C-q] org-set-tag-command
5. You can't see buffer local tags "tag1", "tag2", "workflow", "name" in tags 
completion.

-- 

[ 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


Let `org-element-at-point` or `org-element-context` return element type "tags" when point on tags.

2024-04-07 Thread Christopher M. Miles

When I move point on the headline tags position. I evaluate
`(org-element-at-point)` or `(org-element-context)`, both return element
type is `(headline )`. I hope those two functions can return more
explicit element type like "tags".

I tried to find this type API function in existing functions. But I have
not found. If someone knows, please let me know. I use this function to
detect whether current point is on tags element. I try to write a simple
extension to display tag explanation info through eldoc.

-- 

[ 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


Re: Bug: org-no-popups disregards display-buffer-fallback-action [9.4.6 (9.4.6-13-g4be129-elpaplus @ /home/jeeger/.emacs.d/elpa/org-plus-contrib-20210920/)]

2024-02-07 Thread Christopher M. Miles

+1!

Ihor Radchenko  writes:

> I conclude that `org-no-popups' and `org-switch-to-buffer-other-window'
> should not be used in Org mode.
>
> Fixed, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=78dc58508
>
> Other issues raised in this thread need more thought.


-- 

[ 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


Re: [POLL] Change calling convention for when `org-link-file-path-type' is set to custom function (was: Enhancement Proposal for 'org-link-file-path-type' Behavior)

2024-01-16 Thread Christopher M. Miles

+1 for this propose.

I have one situation need this feature.

Assume a file structure like bellowing:

#+begin_example
`- folder-1
  `- file-1.org
  `- folder-1.2
` file-1.2.1.org
#+end_example

When I try to add link of "file-1.org" in "file-1.2.1.org", based on my
custom option `org-link-file-path-type' value `adaptive'. The link will
become a full-path link. But I want link to be relative to current Org
file path. The file link path should be [[file:../file-1.org]] instead
of [[file:folder-1/file-1.org]]. I hope I can use a custom function in
conditions to decide the file path.

Ihor Radchenko  writes:

> 西 顾  writes:
>
>> I'd like to suggest a small enhancement to the
>> 'org-link-file-path-type' option. When set to 'function', it currently
>> passes an absolute path to the user's custom function. This limits
>> flexibility as the original path input is not available to the
>> function.
>>
>> For better customization, I propose passing the raw path to the
>> function. Users needing an absolute path could use 'expand-file-name'
>> within their function.
>
> Thanks for the suggestion!
>
> This makes sense - the current approach with passing absolute path is
> indeed limiting the information passed to the custom function.
>
> The docstring is also quite ambiguous about what is passed as an
> argument:
>
> org-link-file-path-type is a customizable variable defined in ol.el.
> <...>
> Alternatively, users may supply a custom function that takes the
> full filename as an argument and returns the path.
>
> "full filename" may or may not mean "absolute filename".
>
> However, changing the absolute path to "as is" path will technically be
> breaking.
>
> I cannot find any actual uses of custom function value for
> `org-link-file-path-type' in the wild, so I am leaning towards going
> ahead with this (minor) breaking change.
>
> Yet, I am starting a poll to give users who may be affected a chance to
> chime in.


-- 

[ 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


[DONE] Re: org-agenda + [a] generated many duplicated task entries

2024-01-16 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> When I execute command "org-agenda" with key "[a]" to generate
>> org-agenda day view. Many task entries are duplicated.
>
> Maybe you have something in
> `org-agenda-skip-scheduled-if-deadline-is-shown' or similar customization.
>
>> I tried many methods trying to figure out the problem reason.
>>
>> - [X] Emacs init bisect
>> - [X] Emacs minimal init testing -> no problem
>
> These two mean that you missed something during bisection.

I reproduced the problem with `emacs -Q` and `emacs-minimal-init`.
Then I tried to Edebug on the command function `org-agenda` -> 
`org-agenda-list`.
I suddenly brain come up with checking out the variable `org-agenda-files` 
value.
I found it contains duplicated filenames in list.
Then I added `delete-dups` function around my `org-agenda-files` value list 
generating.
Then the problem solved.

This is really a hard reason to find out which costed lot of time. :(

Anyway, thanks Ihor as always.

-- 

[ 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


Re: org-agenda + [a] generated many duplicated task entries

2024-01-16 Thread Christopher M. Miles

@Ihor, Thanks for your help.

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> When I execute command "org-agenda" with key "[a]" to generate
>> org-agenda day view. Many task entries are duplicated.
>
> Maybe you have something in
> `org-agenda-skip-scheduled-if-deadline-is-shown' or similar customization.
>

I customized `org-agenda-skip-scheduled-if-deadline-is-shown' to `t' in my 
Emacs init.

After your hints, I tested this option with different values:
`nil', `t', `not-today', `repeated-after-deadline'.

None of those value fixed my problem. So should not related to my problem.

I have customized options in my Emacs init:

#+begin_src emacs-lisp
(setq org-agenda-skip-timestamp-if-done t
  org-agenda-skip-deadline-if-done t
  org-agenda-skip-deadline-prewarning-if-scheduled t
  org-agenda-skip-scheduled-if-done t
  org-agenda-skip-scheduled-delay-if-deadline 'post-deadline
  org-agenda-skip-scheduled-if-deadline-is-shown t
  org-agenda-skip-timestamp-if-deadline-is-shown t
  org-agenda-skip-additional-timestamps-same-entry nil
  org-deadline-warning-days 14
  org-agenda-tags-todo-honor-ignore-options t)

(setq org-agenda-todo-ignore-timestamp 'all
  org-agenda-todo-ignore-with-date nil
  org-agenda-todo-ignore-scheduled 'future
  org-agenda-todo-ignore-deadlines 'near)
#+end_src

But I tested by comment out those options still have same problem.

>> I tried many methods trying to figure out the problem reason.
>>
>> - [X] Emacs init bisect
>> - [X] Emacs minimal init testing -> no problem
>
> These two mean that you missed something during bisection.

Yes, this is why I post email here for asking help. Because I can't find
out reason between Emacs init bisect & Emacs minimal init testing.

I will try more times and other methods.

-- 

[ 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


Re: [PATCH] Set Python shell in Org edit buffer

2024-01-11 Thread Christopher M. Miles

Ihor Radchenko  writes:

> Now, the question is what to do with the existing implementation of
> `org-src-associate-babel-session'. It only runs
> org-babel--associate-session when
>
> (and session (not (string= session "none"))
>(org-babel-comint-buffer-livep session)
>(let ((f (intern (format "org-babel-%s-associate-session"
>   (nth 0 info)
>(and (fboundp f) (funcall f session
>
> The questionable check here is (org-babel-comint-buffer-livep session) -
> it only triggers when session is already initiated, while ob-python and
> some other backends do not necessarily need to start a new session to
> "associate" it with Org Src buffer.
>
> I am tentatively inclined to change this check to
>
> (or (org-babel-comint-buffer-livep session)
> (eq org-src-auto-initiate-session t)
> (alist-get (nth 0 info) org-src-auto-initiate-session)
> (alist-get 'default org-src-auto-initiate-session))
>
> With `org-src-auto-initiate-session' being a customization that controls
> whether to associate session for a given babel backend.
>
> We may set the default value to something like
>
> ((default . t) ("R" . nil))

I think this customization is reasonable. Agree to make it as a
customization option, The ob-clojure CIDER session which managed by
"sesman" seems also requires buffer associate with session.

-- 

[ 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


Re: [PATCH v6] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2024-01-11 Thread Christopher M. Miles

Thanks for updating, this patch looks great to me.

-- 

[ 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


[BUG] `org-element-at-point-no-context' error in flyspell `org-mode-flyspell-verify'

2023-11-06 Thread Christopher M. Miles

I got following error:

#+begin_example
Please report this to Org mode mailing list (M-x org-submit-bug-report).
⛔ Warning (org-element-cache): org-element--cache: Org parser error in 
Code.org::434180. Resetting.
 The error was: (wrong-number-of-arguments ((t) nil "Return outline-regexp with 
limited number of levels.
The number of levels is controlled by `org-inlinetask-min-level'." (cond ((not 
(derived-mode-p 'org-mode)) outline-regexp) ((not (featurep 'org-inlinetask)) 
org-outline-regexp) (t (let* ((limit-level (1- org-inlinetask-min-level)) 
(nstars (if org-odd-levels-only (1- (* limit-level 2)) limit-level))) (format 
"\\*\\{1,%d\\} " nstars) 1)
 Backtrace:
"  backtrace-to-string(nil)
  (progn (backtrace-to-string (backtrace-get-frames 'backtrace)))
  (if (and (fboundp 'backtrace-get-frames) (fboundp 'backtrace-to-string)) 
(progn (backtrace-to-string (backtrace-get-frames 'backtrace
  (format \"Org parser error in %s::%S. Resetting.\\n The error was: %S\\n 
Backtrace:\\n%S\\n Please report this to Org mode mailing list (M-x 
org-submit-bug-report).\" (buffer-name (current-buffer)) epom err (if (and 
(fboundp 'backtrace-get-frames) (fboundp 'backtrace-to-string)) (progn 
(backtrace-to-string (backtrace-get-frames 'backtrace)
  (let* ((format-string (format \"Org parser error in %s::%S. Resetting.\\n The 
error was: %S\\n Backtrace:\\n%S\\n Please report this to Org mode mailing list 
(M-x org-submit-bug-report).\" (buffer-name (current-buffer)) epom err (if (and 
(fboundp 'backtrace-get-frames) (fboundp 'backtrace-to-string)) (progn 
(backtrace-to-string (backtrace-get-frames ...)) (format-string (if (or 
(not org-element--cache-diagnostics-ring) (not (eq 'backtrace 
org-element--cache-self-verify))) format-string (prog1 (concat (format 
\"Warning(%s): \" (buffer-name ...)) format-string \"\\nBacktrace:\\n  \" 
(mapconcat #'identity (ring-elements org-element--cache-diagnostics-ring) \"\\n 
 \")) (setq org-element--cache-diagnostics-ring nil) (if (and (boundp 
'org-batch-test) org-batch-test) (error \"%s\" (concat \"org-element--cache: \" 
format-string)) (display-warning 'org-element-cache (concat 
\"org-element--cache: \" format-string
  (condition-case err (org-element--parse-to epom) ((debug error) (let* 
((format-string (format \"Org parser error in %s::%S. Resetting.\\n The error 
was: %S\\n Backtrace:\\n%S\\n Please report this to Org mode mailing list (M-x 
org-submit-bug-report).\" (buffer-name (current-buffer)) epom err (if (and ... 
...) (progn ... (format-string (if (or (not 
org-element--cache-diagnostics-ring) (not ...)) format-string (prog1 (concat 
... format-string \"\\nBacktrace:\\n  \" ...) (setq 
org-element--cache-diagnostics-ring nil) (if (and (boundp 'org-batch-test) 
org-batch-test) (error \"%s\" (concat \"org-element--cache: \" format-string)) 
(display-warning 'org-element-cache (concat \"org-element--cache: \" 
format-string (org-element-cache-reset) (org-element--parse-to epom)))
  (if cached-only (if (and (org-element--cache-active-p) (or (not 
org-element--cache-sync-requests) (< epom (aref (car 
org-element--cache-sync-requests) 1 (progn (org-element--cache-find epom))) 
(condition-case err (org-element--parse-to epom) ((debug error) (let* 
((format-string (format \"Org parser error in %s::%S. Resetting.\\n The error 
was: %S\\n Backtrace:\\n%S\\n Please report this to Org mode mailing list (M-x 
org-submit-bug-report).\" (buffer-name ...) epom err (if ... ...))) 
(format-string (if (or ... ...) format-string (prog1 ... ... (if (and 
(boundp 'org-batch-test) org-batch-test) (error \"%s\" (concat 
\"org-element--cache: \" format-string)) (display-warning 'org-element-cache 
(concat \"org-element--cache: \" format-string (org-element-cache-reset) 
(org-element--parse-to epom
  (setq element (if cached-only (if (and (org-element--cache-active-p) (or (not 
org-element--cache-sync-requests) (< epom (aref (car 
org-element--cache-sync-requests) 1 (progn (org-element--cache-find epom))) 
(condition-case err (org-element--parse-to epom) ((debug error) (let* 
((format-string (format \"Org parser error in %s::%S. Resetting.\\n The error 
was: %S\\n Backtrace:\\n%S\\n Please report this to Org mode mailing list (M-x 
org-submit-bug-report).\" ... epom err ...)) (format-string (if ... 
format-string ...))) (if (and (boundp ...) org-batch-test) (error \"%s\" 
(concat \"org-element--cache: \" format-string)) (display-warning 
'org-element-cache (concat \"org-element--cache: \" format-string 
(org-element-cache-reset) (org-element--parse-to epom)
  (let (element) (if (org-element--cache-active-p) (progn (if (not 
(save-current-buffer (set-buffer (or ... ...)) org-element--cache)) 
(org-element-cache-reset) (if cached-only nil (org-element--cache-sync 
(current-buffer) epom) (setq element (if cached-only (if (and 
(org-element--cache-active-p) (or (not org-element--cache-sync-requests) (< 
epom (aref ... 1 

[BUG] `org-todo` [C-c C-t] got error (args-out-of-range # 0 48016)

2023-11-06 Thread Christopher M. Miles

Here is the backtrace after I toggled debug-on-error:


#+begin_example
Debugger entered--Lisp error: (args-out-of-range # 0 
48016)
  replace-match("")
  (progn (goto-char (match-beginning 0)) (replace-match "") 
(insert-before-markers-and-inherit next) (if (org-invisible-p 
(line-beginning-position)) nil (org-fold-region (line-beginning-position) 
(line-end-position) nil)))
  (unwind-protect (progn (goto-char (match-beginning 0)) (replace-match "") 
(insert-before-markers-and-inherit next) (if (org-invisible-p 
(line-beginning-position)) nil (org-fold-region (line-beginning-position) 
(line-end-position) nil))) (setq org-fold-core--last-buffer-chars-modified-tick 
(buffer-chars-modified-tick)))
  (let ((org-fold-core--ignore-modifications t)) (unwind-protect (progn 
(goto-char (match-beginning 0)) (replace-match "") 
(insert-before-markers-and-inherit next) (if (org-invisible-p 
(line-beginning-position)) nil (org-fold-region (line-beginning-position) 
(line-end-position) nil))) (setq org-fold-core--last-buffer-chars-modified-tick 
(buffer-chars-modified-tick
  (let* ((match-data (match-data)) (startpos (copy-marker 
(line-beginning-position))) (force-log (and (equal arg '...) (prog1 t (setq arg 
nil (logging (let ((saved-match-data ...)) (unwind-protect (progn ...) 
(set-match-data saved-match-data t (org-log-done org-log-done) 
(org-log-repeat org-log-repeat) (org-todo-log-states org-todo-log-states) 
(org-inhibit-logging (if (equal arg 0) (progn (setq arg nil) 'note) 
org-inhibit-logging)) (this (match-string 1)) (hl-pos (match-beginning 0)) 
(head (org-get-todo-sequence-head this)) (ass (assoc head org-todo-kwd-alist)) 
(interpret (nth 1 ass)) (done-word (nth 3 ass)) (final-done-word (nth 4 ass)) 
(org-last-state (or this "")) (completion-ignore-case t) (member (member this 
org-todo-keywords-1)) (tail (cdr member)) (org-state (cond ((eq arg ...) (if 
this ... ...)) ((eq arg ...) (if ... nil ...)) (arg (cond ... ... ... ... ... 
... ... ...)) ((and org-todo-key-trigger org-use-fast-todo-selection) 
(org-fast-todo-selection this)) ((null member) (or head ...)) ((equal this 
final-done-word) nil) ((null tail) nil) ((memq interpret ...) (if ... ... ...)) 
(t (car tail (org-state (or (run-hook-with-args-until-success 
'org-todo-get-default-hook org-state org-last-state) org-state)) (next (if 
(org-string-nw-p org-state) (concat " " org-state " ") " ")) (change-plist 
(list :type 'todo-state-change :from this :to org-state :position startpos)) 
dolog now-done-p) (if org-blocker-hook (progn (let (org-blocked-by-checkboxes 
block-reason) (setq org-last-todo-state-is-todo (not ...)) (if (save-excursion 
...) nil (setq block-reason ...) (if ... ... ... ...) (store-match-data 
match-data) (let ((org-fold-core--ignore-modifications t)) (unwind-protect 
(progn (goto-char (match-beginning 0)) (replace-match "") 
(insert-before-markers-and-inherit next) (if (org-invisible-p ...) nil 
(org-fold-region ... ... nil))) (setq 
org-fold-core--last-buffer-chars-modified-tick (buffer-chars-modified-tick 
(cond ((and org-state (equal this org-state)) (message "TODO state was already 
%s" (org-trim next))) ((not (pos-visible-in-window-p hl-pos)) (message "TODO 
state changed to %s" (org-trim next (if head nil (progn (setq head 
(org-get-todo-sequence-head org-state)) (setq ass (assoc head 
org-todo-kwd-alist)) (setq interpret (nth 1 ass)) (setq done-word (nth 3 ass)) 
(setq final-done-word (nth 4 ass (if (memq arg '(nextset previousset)) 
(progn (message "Keyword-Set %d/%d: %s" (- (length org-todo-sets) -1 (length 
...)) (length org-todo-sets) (mapconcat 'identity (assoc org-state 
org-todo-sets) " " (setq org-last-todo-state-is-todo (not (member org-state 
org-done-keywords))) (setq now-done-p (and (member org-state org-done-keywords) 
(not (member this org-done-keywords (and logging (org-local-logging 
logging)) (if (or (and (or org-todo-log-states org-log-done) (not (eq 
org-inhibit-logging t)) (not (memq arg ...))) force-log) (progn (setq dolog (or 
(if force-log ...) (nth 1 ...) (nth 2 ...))) (if (and (eq dolog ...) (eq 
org-inhibit-logging ...)) (progn (setq dolog ...))) (if (or (and ... ...) (and 
org-state ... ...)) (progn (org-add-planning-info nil nil ...))) (if (and 
now-done-p org-log-done) (progn (org-add-planning-info ... ...) (if ... ...))) 
(if (and org-state dolog) (progn (org-add-log-setup ... org-state this 
dolog) (org-todo-trigger-tag-changes org-state) (if org-auto-align-tags 
(progn (org-align-tags))) (if org-provide-todo-statistics (progn 
(org-update-parent-todo-statistics))) (if (and (boundp 
'org-clock-out-when-done) org-clock-out-when-done) (progn 
(org-clock-out-if-current))) (run-hooks 'org-after-todo-state-change-hook) (if 
(and arg (not (member org-state org-done-keywords))) (progn (setq head 
(org-get-todo-sequence-head org-state (put-text-property 
(line-beginning-position) (line-end-position) 'org-todo-head head) (if 
now-done-p (progn (if 

Re: Unclear where ob-spice.el is being maintained

2023-08-29 Thread Christopher M. Miles

Thanks, Updated now.

Jonas Bernoulli  writes:

> "Christopher M. Miles"  writes:
>
>> Jonas Bernoulli  writes:
>>
>>> In 2022 I changed Melpa to get ob-spice.el from
>>> https://repo.or.cz/ob-spice.git in response to
>>> https://github.com/melpa/melpa/issues/7872#issuecomment-1034945112.
>>>
>>> But org-contrib still contains that file and the README at the new
>>> location still contains
>>>
>>>> This source code is from [[https://github.com/tiagoweber][tiagoweber]].
>>>
>>> and
>>>
>>>> * Project status
>>>>
>>>> I put it in Org-mode contrib/ now.
>>>
>>> So... is this now being maintained by Stardiviner, at repo.or.cz,
>>> or not?
>>>
>>> If so, please update the README at the new location and remove the
>>> library from org-contrib.
>>>
>>>  Cheers,
>>>  Jonas
>>
>> The new repo https://repo.or.cz/ob-spice.git is maintained by me
>> (stardiviner).
>
> Yes, I know you are the maintainer now and that you maintain the
> package at https://repo.or.cz/ob-spice.git.
>
> However https://repo.or.cz/ob-spice.git/blob/HEAD:/README says:
>
> ,
> | * Project status
> | 
> | I put it in Org-mode contrib/ now.
> `
>
> I read this as "this package is being maintained in the "contrib/"
> directory of Org-mode."  It seems to me, this should just be removed.
>
> Further up in the same file it says:
>
> ,
> | * History
> | 
> | This source code is from [[https://github.com/tiagoweber][tiagoweber]].
> |  
> | - The first version is from 
> [[http://tiagoweber.github.io/blog/entry1.html][here]].
> | - The second version is from 
> [[http://tiagoweber.github.io/blog/entry4.html][here]].
> `
>
> This reads to me like "this is my personal fork of
> https://github.com/tiagoweber;.
>
> How about replacing all that with?:
>
> ,
> | ob-spice is now being maintained at https://repo.or.cz/ob-spice.
> | 
> | This package was originally written by 
> [[https://github.com/tiagoweber][Tiago Weber]].
> | You can find more (potentially outdated) information by him about
> | this package [[http://tiagoweber.github.io/blog/entry1.html][here]]
> | and [[http://tiagoweber.github.io/blog/entry4.html][here]].
> `


-- 

[ 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


Re: Unclear where ob-spice.el is being maintained

2023-08-27 Thread Christopher M. Miles

Jonas Bernoulli  writes:

> In 2022 I changed Melpa to get ob-spice.el from
> https://repo.or.cz/ob-spice.git in response to
> https://github.com/melpa/melpa/issues/7872#issuecomment-1034945112.
>
> But org-contrib still contains that file and the README at the new
> location still contains
>
>> This source code is from [[https://github.com/tiagoweber][tiagoweber]].
>
> and
>
>> * Project status
>>
>> I put it in Org-mode contrib/ now.
>
> So... is this now being maintained by Stardiviner, at repo.or.cz,
> or not?
>
> If so, please update the README at the new location and remove the
> library from org-contrib.
>
>  Cheers,
>  Jonas

The new repo https://repo.or.cz/ob-spice.git is maintained by me (stardiviner).

-- 

[ 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


Re: Unclear where ob-spice.el is being maintained

2023-08-27 Thread Christopher M. Miles

Jonas Bernoulli  writes:

> Ihor Radchenko  writes:
>
>> Jonas Bernoulli  writes:
>>
>>> In 2022 I changed Melpa to get ob-spice.el from
>>> https://repo.or.cz/ob-spice.git in response to
>>> https://github.com/melpa/melpa/issues/7872#issuecomment-1034945112.
>>
>> The last discussion was back in 2020 
>> https://list.orgmode.org/orgmode/cal1eyul8zzg-fdeedovbvm1cfc8w6ajwfr7cthvgs8owdwj...@mail.gmail.com/
>
> Bastien replied to that mentioning only one of the listed packages,
> which left me wondering "what about the others?".
>
>> However, your reference is 2022.
>> So, unless Christopher has something to say,
>> https://repo.or.cz/ob-spice.git is the last known active maintenance
>> location. The last commit is 2022
>> https://repo.or.cz/ob-spice.git/shortlog, and includes more changes
>> compared to ob-spice version in org-contrib.
>
> I came to the same conclusion but because ob-spice had not been removed
> from org-contrib, I wasn't sure.  Ihor, could you please remove it from
> org-contrib now?

I have already forget whether I taken the ob-spice maintaining task like
other libraries. So I'm not sure about it. I'm not work on this library
currently. From git log history, I'm the last maintainer. If you want to
maintain it or avoid duplicate, you can ask Bastien to remove it.

> Stardiviner, the readme in your repository still claims that the package
> is being maintained in two other locations.  Please remove that outdated
> information.
>

I have not found claimed two other locations in my README. Maybe I
missed out. Can you point out?

-- 

[ 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


Re: [PATCH v3.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-04 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> With your patch, it will become impossible to display linked images
>>> using interactive command.
>>
>> Does this code match the needs?
>
> Please check my latest reply 
> (https://list.orgmode.org/87o7jpoqfl.fsf@localhost/T/#m25fbb254635512a7bf86d368bf93a24a1c2fb3f1).
> I think we may go away without introducing an extra defcustom.

After yesterday night studying source code, I still can't figure out
solution. So I pass this patch to you. Wait you to finish the unfinished
part of path.

-- 

[ 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


Re: [PATCH v3.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-04 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> The problem here is backwards compatibility. `org-toggle-inline-images'
>>> is bound to C-c C-x C-v and people may be used to C-u C-c C-x C-v
>>> displaying linked images like
>>>
>>> [[https://orgmode.org/resources/img/org-mode-unicorn.svg][description]]
>>>
>>> I will need to think more how to approach this.
>>>
>>
>> Indeed.
>
> Another problem with your change is that the order of arguments changed.
> If there is some Elisp doing something like
> (org-toggle-inline-images INCLUDE-LINKED), your patch will break the
> code.
>
> I think that instead of changing the existing function, we can convert
> your patch into a new function `org-toggle-inline-images-command' that
> will be free to alter the argument order. We can then re-bind that
> function in org-keys to make it used by default, but only interactively.
>

I don't think so, the patch main purpose is for improve image refreshing
after babel result image displaying. Because the function is hooked by
other ob-* packages. Another purpose is headline level images displaying.
So modifying this function is the only way.

> As for displaying linked images, what about something like
>
>
> C-1 C-c C-x C-v being equivalent of
> C-c C-x C-v + INCLUDE-LINKED=t
> (display in current section/region, with linked)
>
> and
>
> C-11 C-c C-x C-v being equivalent of
> C-u C-u C-c C-x C-v + INCLUDE-LINKED=t
> (display in the whole buffer, with linked)
>

Don't know, I have not use it this way. I think INCLUDE-LINKED is just a
option argument for function org-display-inline-images. No need to be
available for toggle in interactive command. An option like
org-inline-images-include-linked is enough.

>> +(defun org-toggle-inline-images ( arg include-linked beg end)
>> +  "Toggle the display of inline images at point.
>> +INCLUDE-LINKED is passed to `org-display-inline-images'.
>> +
>> +If cursor is on an inline image link, display the inline image.
>> +If there is none, remove it otherwise.
>
> I do not quite understand what the last line is trying to say.

Emmm, I forget the meaning of it. I read the docstring again, seems it
can be deleted. I will delete it in my patch.

-- 

[ 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


Re: [PATCH v3.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-02 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I think current patch is ready for merging now. WDYT?
>
> No, unfortunately.
> With your patch, it will become impossible to display linked images
> using interactive command.

Does this code match the needs?

#+begin_src emacs-lisp
   ;; [M-1] / [C-1] argument for linked images like:
   ;; [[https://orgmode.org/resources/img/org-mode-unicorn.svg][description]]
   ((equal arg 1)
(setq org-inline-images-include-linked (not 
org-inline-images-include-linked))
(let ((current-prefix-arg nil))
  (org-toggle-inline-images nil org-inline-images-include-linked)))
#+end_src

-- 

[ 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


Re: [PATCH v3.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-02 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I think current patch is ready for merging now. WDYT?
>
> No, unfortunately.
> With your patch, it will become impossible to display linked images
> using interactive command.

I still need time to study how to add support for this. Most likely I
can't implement it by myself. Would you modify my patch to add support
for this?

-- 

[ 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


[PATCH v3.1] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> This is not a toggle. This is unconditional refresh.
>>>
>> Yes, indeed it's a unconditional refresh. It does not match the meaning of 
>> word "toggle".
>>
>> Seems need to detect whether has image overlays in region. I added this
>> detection in new patch. Like bellowing:
>>
>> #+begin_src emacs-lisp
>> ...
>> ((use-region-p)
>> (if (seq-contains-p
>>  (mapcar
>>   (lambda (ov)
>> (plist-get (overlay-properties ov) 'org-image-overlay))
>>   (overlays-in beg end))
>>  t)
>
> You can just use `org--inline-image-overlays'.
>

Aha, I forget this API function, I applied in new patch.

>>> And there is no clean way to allow INCLUDE-LINKED while keeping
>>> consistency with latex preview commands.
>>
>> About the INCLUDE-LINKED argument, I don't know how to process it. In
>> theory, it should be handled by function org-display-inline-images
>> instead of org-toggle-inline-images. If you have improvements on it, can
>> you add code on my patch?
>
> The problem here is backwards compatibility. `org-toggle-inline-images'
> is bound to C-c C-x C-v and people may be used to C-u C-c C-x C-v
> displaying linked images like
>
> [[https://orgmode.org/resources/img/org-mode-unicorn.svg][description]]
>
> I will need to think more how to approach this.
>

Indeed.

>>> What we might do here is making a new defcustom that will control
>>> whether linked images should be displayed. Then, something like C-1
>>> org-toggle-inline-images could toggle that defcustom and refresh all the
>>> image previews in buffer (if any).
>>>
>>> WDYT?
>>
>> Refreshing all image previews in buffer is same as old behavior.
>
> Sure. But the idea of this specific C-1 prefix argument is to toggle the
> hypothetical defcustom `org-inline-images-include-linked'. If we flip it
> we may need to remove/add linked image previews or otherwise risk users
> being confused by the defcustom not taking effect.

I checked source code, don't know where to insert this functionality.
Is it be in `org-display-inline-images` or somewhere else?
I will find time to checking code whether can add this in another patch.
If you have plan for this, let me know.

I think current patch is ready for merging now. WDYT?

From 2f68f0172dc5e452c05a9d254eab8ae797bcd15b Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Mon, 22 May 2023 16:25:33 +0800
Subject: [PATCH] org: Improve inline images displaying like LaTeX previewing

* lisp/org.el (org-toggle-inline-images): Implement LaTeX previewing
same logic in inline images toggle displaying.
---
 lisp/org.el | 89 -
 1 file changed, 74 insertions(+), 15 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index e72cf056a..04f713d26 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16160,22 +16160,81 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
   (when (memq ov org-inline-image-overlays)
 (push ov result)
 
-(defun org-toggle-inline-images ( include-linked beg end)
-  "Toggle the display of inline images.
-INCLUDE-LINKED is passed to `org-display-inline-images'."
+(defun org-toggle-inline-images ( arg include-linked beg end)
+  "Toggle the display of inline images at point.
+INCLUDE-LINKED is passed to `org-display-inline-images'.
+
+If cursor is on an inline image link, display the inline image.
+If there is none, remove it otherwise.
+If there is no inline image link at point, display all inline images in the current section.
+With an active region, display inline images in the region.
+
+With a `\\[universal-argument]' prefix argument ARG, clear inline
+images in the current section.
+
+With a `\\[universal-argument] \\[universal-argument]' prefix
+ argument ARG, display all inline images in the buffer.
+
+With a `\\[universal-argument] \\[universal-argument] \
+\\[universal-argument]' prefix argument ARG, clear all inline
+images in the buffer."
   (interactive "P")
-  (if (org--inline-image-overlays beg end)
-  (progn
-(org-remove-inline-images beg end)
-(when (called-interactively-p 'interactive)
-	  (message "Inline image display turned off")))
-(org-display-inline-images include-linked nil beg end)
-(when (called-interactively-p 'interactive)
-  (let ((new (org--inline-image-overlays beg end)))
-(message (if new
-		 (format "%d images displayed inline"
-			 (length new))
-		   "No images to display inline"))
+  (cond
+   ((not (display-graphic-p)) nil)
+   ;; Clear whole buffer inline images.
+   ((equal 

[PATCH v3] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-08-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> Unlike `org-latex-preview', here we need to (1) respect active region;
>>> (2) keep the backward compatibility for INCLUDE-LINKED.
>>>
>>> For (1), for example, it would make sense to respect region when prefix
>>> argument is C-u and clear images only there. For (2), we need to at
>>> least allow toggling images with description using some prefix argument
>>> (previously, any prefix argument would do).
>>
>> I indeed implemented all same behavior like `org-latex-preview' in new
>> `org-toggle-inline-images'.
>>
>> ...
>> And I also implement the toggle inline images in region logic in
>> `org-toggle-inline-images' as bellowing:
>>
>> ;; Display region selected inline images.
>>((use-region-p)
>> (message "Displaying inline images in region...")
>> (org-display-inline-images include-linked t (region-beginning) 
>> (region-end))
>> (message "Displaying inline images in region... done."))
>
> This is not a toggle. This is unconditional refresh.
>
Yes, indeed it's a unconditional refresh. It does not match the meaning of word 
"toggle".

Seems need to detect whether has image overlays in region. I added this
detection in new patch. Like bellowing:

#+begin_src emacs-lisp
...
((use-region-p)
(if (seq-contains-p
 (mapcar
  (lambda (ov)
(plist-get (overlay-properties ov) 'org-image-overlay))
  (overlays-in beg end))
 t)
(progn
  (org-remove-inline-images beg end)
  (message "Inline images in region removed."))
  (message "Displaying inline images in region...")
  (org-display-inline-images include-linked nil (region-beginning) 
(region-end))
  (message "Displaying inline images in region... done.")))

#+end_src

>> For (2), It's working. The code passed the parameter `include-linked' to
>> `org-display-inline-images'. So they works in any case of [C-u] prefix.
>
> My concern is that previously C-u M-x org-toggle-inline-images would
> "display links with a text description part". With your patch, it is no
> longer the case because INCLUDE-LINKED is not affected by the prefix
> argument.
>
> And there is no clean way to allow INCLUDE-LINKED while keeping
> consistency with latex preview commands.

About the INCLUDE-LINKED argument, I don't know how to process it. In
theory, it should be handled by function org-display-inline-images
instead of org-toggle-inline-images. If you have improvements on it, can
you add code on my patch?

>
> What we might do here is making a new defcustom that will control
> whether linked images should be displayed. Then, something like C-1
> org-toggle-inline-images could toggle that defcustom and refresh all the
> image previews in buffer (if any).
>
> WDYT?

Refreshing all image previews in buffer is same as old behavior. My
patch's purpose is to improve function org-toggle-inline-images behavior
which refresh only in current level scope instead of whole buffer with
lot of inline images especially heavy and suspend Emacs. Because
function org-toggle-inline-images is used in of lot Emacs ob-* related
packages on after babel execution hook. Old behavior caused execute one
source block need to refresh whole buffer all images. Instead of only
current headline images, or just results image.

From 635624cb8446791b9e39f2803077ac9fa6d17225 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Mon, 22 May 2023 16:25:33 +0800
Subject: [PATCH] org: Improve inline images displaying like LaTeX previewing

* lisp/org.el (org-toggle-inline-images): Implement LaTeX previewing
same logic in inline images toggle displaying.
---
 lisp/org.el | 92 -
 1 file changed, 77 insertions(+), 15 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index e72cf056a..f847a42e7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16160,22 +16160,84 @@ SNIPPETS-P indicates if this is run to create snippet images for HTML."
   (when (memq ov org-inline-image-overlays)
 (push ov result)
 
-(defun org-toggle-inline-images ( include-linked beg end)
-  "Toggle the display of inline images.
-INCLUDE-LINKED is passed to `org-display-inline-images'."
+(defun org-toggle-inline-images ( arg include-linked beg end)
+  "Toggle the display of inline images at point.
+INCLUDE-LINKED is passed to `org-display-inline-images'.
+
+If cursor is on an inline image link, display the inline image.
+If there is none, remove it otherwise.
+If there is no inline image link at point, display all inline images in the current section.
+With an active region, display inline images in the region.
+
+With

[PATCH v5] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-07-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I improved the code a little. Can't figure out how to implement upper logic.
>> Can you finish the last part? Thanks
>>
>> #+begin_src emacs-lisp
>> (setq tbl (let* ((tags-grouped (org-tag-alist-to-groups fulltable))
>>...
>
> I tried to improve the code readability in `org-fast-tag-selection'.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a19654583c6f2070096402bc712591a0a2c80d01
>
> May you look at it again and see if you can manage to implement a full
> patch now?

Ok, I update and re-generated the patch, also add new document and Org NEWS 
entries.

Review it, if has problem, notify me to modify. Thanks



0001-org-Improve-the-tags-fast-selection-performance.patch
Description: 

-- 

[ 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


[SOLVED] Re: [QUESTION] Hope to improve the `org-set-font-lock-defaults` performance by lazy and limit to current visible area

2023-05-25 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I'm the developer of Org mode package "org-link-beautify"
>> https://repo.or.cz/org-link-beautify.git . The package main theory
>> is to use org-link-parameters `:activate-func` to do link file preview
>> with generating thumbnail images or file content etc.
>>
>> But I found it's slow one some big Org file and slow on small Org file
>> when previewing has a lot.
>> ...
>> I can see the `org-mode` invoked `org-set-font-lock-defaults` soon when
>> `org-mode` enabled. I hope the link `:activate-func` function can be
>> called only on link elements which is VISIBLE (means unfolded subtrees
>> or similar). So org-mode don't need to render all buffer links at
>> beginning soon. Instead render them as needed as unfolded. (Maybe I read
>> source code without fully understand the code. If so, correct me,
>> thanks.)
>
> Emacs fontification, by default, only requests fontification of the text
> visible on screen. That's what LIMIT argument to `font-lock-keywords'
> MATCHER function is for. Org mode obeys LIMIT.
>
> If you are seeing fontification being requested for invisible part of
> buffer or parts of buffer outside screen, it is likely caused by some
> third-party package forcing the fontification.
>
> As usual, try emacs -Q + minimal set of loaded packages and see if you
> can reproduce the problem.

Ihor, Thanks for answering. Learned new stuff.

-- 

[ 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


[QUESTION] Hope to improve the `org-set-font-lock-defaults` performance by lazy and limit to current visible area

2023-05-24 Thread Christopher M. Miles

I'm the developer of Org mode package "org-link-beautify"
https://repo.or.cz/org-link-beautify.git . The package main theory
is to use org-link-parameters `:activate-func` to do link file preview
with generating thumbnail images or file content etc.

But I found it's slow one some big Org file and slow on small Org file
when previewing has a lot.

I locate and studied the source code of the `:activate-func`.

- [X] locate the core function source code
  + [X] org-link-set-parameters
- [X] org-link-parameters
  + [X] :activate-func
  + [X] org-mode major mode definition
+ [X] org-set-font-lock-defaults - Set font lock defaults for the current 
buffer.
  - [X] variable: org-font-lock-extra-keywords - dynamically scoped
+ [X] org-activate-links
  - [X] org-activate-links--text-properties
+ [X] :activate-func
  - [X] org-activate-links--overlays
+ [X] :activate-func

I can see the `org-mode` invoked `org-set-font-lock-defaults` soon when
`org-mode` enabled. I hope the link `:activate-func` function can be
called only on link elements which is VISIBLE (means unfolded subtrees
or similar). So org-mode don't need to render all buffer links at
beginning soon. Instead render them as needed as unfolded. (Maybe I read
source code without fully understand the code. If so, correct me,
thanks.)

So, I hope Org mode maintainer can improve this mechanism. Thanks a lot.

Hope this can improve other Org mode extensions performance too.

-- 

[ 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


[PATCH v4.1] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-16 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>>> (seq-take (seq-uniq (append bound-tags 
>>>> fulltable))
>>>>   org-fast-tag-selection-maximum-tags))
>>>
>>> This will behave awkwardly with tag groups. You may better use 
>>> `org--tag-add-to-alist'.
>>
>> I think here should use `append' instead of `org--tag-add-to-alist' to merge.
>
> Yeah. `org--tag-add-to-alist' does not tell it, but it actually prefers
> keeping duplicate tag copies from its second argument.
>
> Yet, however, tags with their binding assigned might occur inside a
> group. Your code will incorrectly pull them out.
>
> I think that the right approach to handle tag groups and explicitly
> bound tags is showing them all the time, even when the total number of
> tags exceeds the limit:
>
> 1. If a tag is bound explicitly (cdr non-nil) show it
> 2. If a tag is inside a group - show it
> 3. If there is still some room left, show up to the limit.
>
> My logic is that tag groups and bound tags can only be customized by the
> user. So, it makes sense to display them all the time - users likely
> expect such behaviour.
>
> WDYT?

I improved the code a little. Can't figure out how to implement upper logic.
Can you finish the last part? Thanks

#+begin_src emacs-lisp
(setq tbl (let* ((tags-grouped (org-tag-alist-to-groups fulltable))
 (fulltable-accurate (flatten-list 
(org-tag-alist-to-groups fulltable)))
 (bound-tags (seq-filter 'cdr fulltable)))
;; TODO: consider tag groups.
;; the right approach to handle tag groups and explicitly
;; bound tags is showing them all the time, even when the 
total number of
;; tags exceeds the limit
;; 
;; 1. If a tag is bound explicitly (cdr non-nil) show it
;; 2. If a tag is inside a group - show it
;; 3. If there is still some room left, show up to the 
limit.
(if (length< fulltable-accurate 
org-fast-tag-selection-maximum-tags)
fulltable
  (if (length< bound-tags 
org-fast-tag-selection-maximum-tags)
  (progn
(insert (format-message "Tags are limited displayed 
by `org-fast-tag-selection-maximum-tags'.\n"))
;; TODO:
(seq-take (seq-uniq (org--tag-add-to-alist 
bound-tags fulltable))
  org-fast-tag-selection-maximum-tags))
(insert "Tags are limited displayed only has key 
bound.\n")
bound-tags)))
  char ?a cnt 0)
#+end_src

-- 

[ 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


[PATCH v4] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-16 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> Updated version which fix the `message` error in upper code:
>
> Thanks!
>
>> #+begin_src emacs-lisp
>> (setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
>> (if (length< fulltable 
>> org-fast-tag-selection-maximum-tags)
>
> Because of (:startgroup) markers and similar things, this condition is
> not fully accurate. See `org-tag-alist' docstring.
>
> You may also need to consider special alist items in the rest of the code.
>
I added a let-binding to modify fulltable at first to filter out special tag 
markers.

>> fulltable
>>   (if (length< bound-tags 
>> org-fast-tag-selection-maximum-tags)
>>   (progn
>> (insert "Tags are limited displayed by 
>> `org-fast-tag-selection-maximum-tags'.\n")
>
> If you want to have proper Elisp symbol markup when using `...', use
> `format-message'.

Updated.

>
>> (seq-take (seq-uniq (append bound-tags 
>> fulltable))
>>   org-fast-tag-selection-maximum-tags))
>
> This will behave awkwardly with tag groups. You may better use 
> `org--tag-add-to-alist'.

I think here should use `append' instead of `org--tag-add-to-alist' to merge.

Using `append':

#+begin_example
Inherited:  video
Current:

Tags are limited displayed by ‘org-fast-tag-selection-maximum-tags’.
  [d] drill   [z] crypt 
  [A] ARCHIVE 
  [E] noexport[P] private   
  [D] deprecated  
  [O] outdated[t] translate 
  [i] idea
  [h] book[b] bookmark  
  [w] work
  [a] appointment [m] meeting   
  [u] urgent  
  [X] SEX [k] wiki  
  [C] code
  [e] Emacs   [o] Org_mode  
  [G] git 
  [L] Linux   [M] macOS 
  [W] Windows 
  [l] LISP[c] Clojure   
  [s] ClojureScript   
  [J] Java[S] Shell 
  [p] Python  
  [r] Ruby[j] JavaScript
  [d] database
  [f] LOG [g] @marks
  [n] on  
  [q] off [v] star  
  [x] like
  [y] favorite[{] suggested 
  [|] heart   
  [}] smile   [~] brain 
  [ ] check   
  [ ] alert   [ ] important 
  [ ] flag
  [ ] error   [ ] label 
  
#+end_example

Using `org--tag-add-to-alist':

#+begin_example
Inherited:  video
Current:

Tags are limited displayed by ‘org-fast-tag-selection-maximum-tags’.
  [d] drill   [z] crypt 
  [f] LOG 
  [A] ARCHIVE [E] noexport  
  [P] private 
  [D] deprecated  [O] outdated  
  [g] @marks  
  [n] on  [q] off   
  [v] star
  [x] like[y] favorite  
  [{] suggested   
  [|] heart   [}] smile 
  [~] brain   
  [ ] check   [ ] alert 
  [ ] important   
  [ ] flag[ ] error 
  [ ] label   
  [ ] question[ ] info  
  [ ] quote   
  [ ] table  

Re: [PATCH v2] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-05-16 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> I'd prefer something more closely resembling `org-latex-preview'
>>> approach with prefix arguments:
>>> ...
>>> `org-toggle-inline-images' should also be changed.
>>
>> Here is the source code of `org-toggle-inline-images'. I implement this
>> by reference `org-latex-preview'. I have not write testing, but only
>> manually tested with Edebug and on actual Org buffer displaying and
>> disable inline images. The command works fine. Ihor, can you review the code?
>
> Unlike `org-latex-preview', here we need to (1) respect active region;
> (2) keep the backward compatibility for INCLUDE-LINKED.
>
> For (1), for example, it would make sense to respect region when prefix
> argument is C-u and clear images only there. For (2), we need to at
> least allow toggling images with description using some prefix argument
> (previously, any prefix argument would do).

I indeed implemented all same behavior like `org-latex-preview' in new
`org-toggle-inline-images'.

For (1), org-latex-preview has a `cond' logic to toggle preview in
region. Here is the code from `org-latex-preview'.

((use-region-p)
(message "Creating LaTeX previews in region...")
(org--latex-preview-region (region-beginning) (region-end))
(message "Creating LaTeX previews in region... done."))

+

;; Clear current section.
   ((equal arg '(4))
(org-clear-latex-preview
 (if (use-region-p)
 (region-beginning)
   (if (org-before-first-heading-p) (point-min)
 (save-excursion
   (org-with-limited-levels (org-back-to-heading t) (point)
 (if (use-region-p)
 (region-end)
   (org-with-limited-levels (org-entry-end-position)

And I also implement the toggle inline images in region logic in
`org-toggle-inline-images' as bellowing:

;; Display region selected inline images.
   ((use-region-p)
(message "Displaying inline images in region...")
(org-display-inline-images include-linked t (region-beginning) (region-end))
(message "Displaying inline images in region... done."))

+

;; Clear current section.
   ((equal arg '(4))
(org-clear-latex-preview
 (if (use-region-p)
 (region-beginning)
   (if (org-before-first-heading-p) (point-min)
 (save-excursion
   (org-with-limited-levels (org-back-to-heading t) (point)
 (if (use-region-p)
 (region-end)
   (org-with-limited-levels (org-entry-end-position)



For (2), It's working. The code passed the parameter `include-linked' to
`org-display-inline-images'. So they works in any case of [C-u] prefix.

Maybe you want to eval the patch code to test.

-- 

[ 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


[PATCH v4] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-16 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> Updated version which fix the `message` error in upper code:
>
> Thanks!
>
>> #+begin_src emacs-lisp
>> (setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
>> (if (length< fulltable 
>> org-fast-tag-selection-maximum-tags)
>
> Because of (:startgroup) markers and similar things, this condition is
> not fully accurate. See `org-tag-alist' docstring.
>
> You may also need to consider special alist items in the rest of the code.
>
I added a let-binding to modify fulltable at first to filter out special tag 
markers.

>> fulltable
>>   (if (length< bound-tags 
>> org-fast-tag-selection-maximum-tags)
>>   (progn
>> (insert "Tags are limited displayed by 
>> `org-fast-tag-selection-maximum-tags'.\n")
>
> If you want to have proper Elisp symbol markup when using `...', use
> `format-message'.

Updated.

>
>> (seq-take (seq-uniq (append bound-tags 
>> fulltable))
>>   org-fast-tag-selection-maximum-tags))
>
> This will behave awkwardly with tag groups. You may better use 
> `org--tag-add-to-alist'.

I think here should use `append' instead of `org--tag-add-to-alist' to merge.

Using `append':

#+begin_example
Inherited:  video
Current:

Tags are limited displayed by ‘org-fast-tag-selection-maximum-tags’.
  [d] drill   [z] crypt 
  [A] ARCHIVE 
  [E] noexport[P] private   
  [D] deprecated  
  [O] outdated[t] translate 
  [i] idea
  [h] book[b] bookmark  
  [w] work
  [a] appointment [m] meeting   
  [u] urgent  
  [X] SEX [k] wiki  
  [C] code
  [e] Emacs   [o] Org_mode  
  [G] git 
  [L] Linux   [M] macOS 
  [W] Windows 
  [l] LISP[c] Clojure   
  [s] ClojureScript   
  [J] Java[S] Shell 
  [p] Python  
  [r] Ruby[j] JavaScript
  [d] database
  [f] LOG [g] @marks
  [n] on  
  [q] off [v] star  
  [x] like
  [y] favorite[{] suggested 
  [|] heart   
  [}] smile   [~] brain 
  [ ] check   
  [ ] alert   [ ] important 
  [ ] flag
  [ ] error   [ ] label 
  
#+end_example

Using `org--tag-add-to-alist':

#+begin_example
Inherited:  video
Current:

Tags are limited displayed by ‘org-fast-tag-selection-maximum-tags’.
  [d] drill   [z] crypt 
  [f] LOG 
  [A] ARCHIVE [E] noexport  
  [P] private 
  [D] deprecated  [O] outdated  
  [g] @marks  
  [n] on  [q] off   
  [v] star
  [x] like[y] favorite  
  [{] suggested   
  [|] heart   [}] smile 
  [~] brain   
  [ ] check   [ ] alert 
  [ ] important   
  [ ] flag[ ] error 
  [ ] label   
  [ ] question[ ] info  
  [ ] quote   
  [ ] table  

[PATCH v3.1] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-15 Thread Christopher M. Miles

"Christopher M. Miles"  writes:

> [[PGP Signed Part:Undecided]]
>
> Ihor Radchenko  writes:
>
>> "Christopher M. Miles"  writes:
>>
>>>> You are almost there.
>>>> Just run your code only when (lentgh> fulltable 26).
>>>>
>>>> Of course, 26 should be a defcustom rather than a hard-coded constant.
>>>> And do the same for `org-fast-todo-selection'.
>>>
>>> Ok, I added defcustom option, and add cl-case condition on custom option
>>> `org-use-fast-tag-selection'.
>>
>> I do not think that we need to care about the value of
>> `org-use-fast-tag-selection'.  Instead, just
>>
>> 1. If the total number of tags does not exceed
>>`org-fast-tag-selection-maximum-tags', display them all.
>> 2. If the total number of tags is larger, just display all the bound
>>tags + any extra tags, up to `org-fast-tag-selection-maximum-tags',
>>and add a note in the tag selection buffer that more tags are not
>>displayed.
>
> Ok, I re-implemented the mechanism like bellowing, can you check whether it 
> fits?
>
> #+begin_src emacs-lisp
> (setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
> (if (length< fulltable 
> org-fast-tag-selection-maximum-tags)
> fulltable
>   (if (length< bound-tags 
> org-fast-tag-selection-maximum-tags)
>   (progn
> (seq-take (seq-uniq (append bound-tags fulltable))
>   org-fast-tag-selection-maximum-tags)
> (message "Tags are limited displayed by 
> `org-fast-tag-selection-maximum-tags'."))
> bound-tags
> (message "Tags are limited displayed only has key 
> bound."
>   char ?a cnt 0)
> #+end_src

Updated version which fix the `message` error in upper code:

#+begin_src emacs-lisp
(setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
(if (length< fulltable org-fast-tag-selection-maximum-tags)
fulltable
  (if (length< bound-tags 
org-fast-tag-selection-maximum-tags)
  (progn
(insert "Tags are limited displayed by 
`org-fast-tag-selection-maximum-tags'.\n")
(seq-take (seq-uniq (append bound-tags fulltable))
  org-fast-tag-selection-maximum-tags))
(insert "Tags are limited displayed only has key 
bound.\n")
bound-tags)))
  char ?a cnt 0)
#+end_src

-- 

[ 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


Re: [PATCH] org-crypt-decrypt-entry: Apply initial visibility upon decryption

2023-05-15 Thread Christopher M. Miles

No objection

-- 

[ 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


[PATCH v3] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-15 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> You are almost there.
>>> Just run your code only when (lentgh> fulltable 26).
>>>
>>> Of course, 26 should be a defcustom rather than a hard-coded constant.
>>> And do the same for `org-fast-todo-selection'.
>>
>> Ok, I added defcustom option, and add cl-case condition on custom option
>> `org-use-fast-tag-selection'.
>
> I do not think that we need to care about the value of
> `org-use-fast-tag-selection'.  Instead, just
>
> 1. If the total number of tags does not exceed
>`org-fast-tag-selection-maximum-tags', display them all.
> 2. If the total number of tags is larger, just display all the bound
>tags + any extra tags, up to `org-fast-tag-selection-maximum-tags',
>and add a note in the tag selection buffer that more tags are not
>displayed.

Ok, I re-implemented the mechanism like bellowing, can you check whether it 
fits?

#+begin_src emacs-lisp
(setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
(if (length< fulltable org-fast-tag-selection-maximum-tags)
fulltable
  (if (length< bound-tags 
org-fast-tag-selection-maximum-tags)
  (progn
(seq-take (seq-uniq (append bound-tags fulltable))
  org-fast-tag-selection-maximum-tags)
(message "Tags are limited displayed by 
`org-fast-tag-selection-maximum-tags'."))
bound-tags
(message "Tags are limited displayed only has key 
bound."
  char ?a cnt 0)
#+end_src

-- 

[ 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


Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-05-15 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> The `org-redisplay-inline-images' will refresh whole buffer inline
>> images. When the buffer is a big Org file, and not all inline images are
>> display already by default (still image file links under fold status).
>> Invoking `org-redisplay-inline-images' will cause Emacs suspend a long
>> time.
>>
>> So I suggest to add an variant local function of
>> `org-redisplay-inline-images' which named
>> `org-redisplay-inline-images-under-headline' that only redisplay inline
>> images under current headline to solve the issue.
>>
>> Here is the diff code prototype, Ihor, can you review it? If it's ok, I
>> will send patch update then.
>
> I'd prefer something more closely resembling `org-latex-preview'
> approach with prefix arguments:
>
> Toggle preview of the LaTeX fragment at point.
> 
> If the cursor is on a LaTeX fragment, create the image and
> overlay it over the source code, if there is none.  Remove it
> otherwise.  If there is no fragment at point, display images for
> all fragments in the current section.  With an active region,
> display images for all fragments in the region.
> 
> With a C-u prefix argument ARG, clear images for all fragments
> in the current section.
> 
> With a C-u C-u prefix argument ARG, display image for all
> fragments in the buffer.
> 
> With a C-u C-u C-u prefix argument ARG, clear image for all
> fragments in the buffer.
>
> `org-toggle-inline-images' should also be changed.

I agree this solution. I will check out latex fragment preview source
code whether I can implement this.

-- 

[ 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


[PATCH v2] Re: [PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-05-15 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> The `org-redisplay-inline-images' will refresh whole buffer inline
>> images. When the buffer is a big Org file, and not all inline images are
>> display already by default (still image file links under fold status).
>> Invoking `org-redisplay-inline-images' will cause Emacs suspend a long
>> time.
>>
>> So I suggest to add an variant local function of
>> `org-redisplay-inline-images' which named
>> `org-redisplay-inline-images-under-headline' that only redisplay inline
>> images under current headline to solve the issue.
>>
>> Here is the diff code prototype, Ihor, can you review it? If it's ok, I
>> will send patch update then.
>
> I'd prefer something more closely resembling `org-latex-preview'
> approach with prefix arguments:
>
> Toggle preview of the LaTeX fragment at point.
> 
> If the cursor is on a LaTeX fragment, create the image and
> overlay it over the source code, if there is none.  Remove it
> otherwise.  If there is no fragment at point, display images for
> all fragments in the current section.  With an active region,
> display images for all fragments in the region.
> 
> With a C-u prefix argument ARG, clear images for all fragments
> in the current section.
> 
> With a C-u C-u prefix argument ARG, display image for all
> fragments in the buffer.
> 
> With a C-u C-u C-u prefix argument ARG, clear image for all
> fragments in the buffer.
>
> `org-toggle-inline-images' should also be changed.

Here is the source code of `org-toggle-inline-images'. I implement this
by reference `org-latex-preview'. I have not write testing, but only
manually tested with Edebug and on actual Org buffer displaying and
disable inline images. The command works fine. Ihor, can you review the code?

#+begin_src emacs-lisp
(defun org-toggle-inline-images ( arg include-linked beg end)
  "Toggle the display of inline images at point.
INCLUDE-LINKED is passed to `org-display-inline-images'.

If cursor is on an inline image link, display the inline image.
If there is none, remove it otherwise.
If there is no inline image link at point, display all inline images in the 
current section.
With an active region, display inline images in the region.

With a `\\[universal-argument]' prefix argument ARG, clear inline
images in the current section.

With a `\\[universal-argument] \\[universal-argument]' prefix
 argument ARG, display all inline images in the buffer.

With a `\\[universal-argument] \\[universal-argument] \
\\[universal-argument]' prefix argument ARG, clear all inline
images in the buffer."
  (interactive "P")
  (cond
   ((not (display-graphic-p)) nil)
   ;; Clear whole buffer inline images.
   ((equal arg '(64))
(org-remove-inline-images (point-min) (point-max))
(message "Inline images preview disabled in buffer."))
   ;; Display whole buffer inline images.
   ((equal arg '(16))
(message "Displaying all inline images in buffer...")
(org-display-inline-images include-linked nil (point-min) (point-max))
(message "Displaying all inline images in buffer... done."))
   ;; Clear current section.
   ((equal arg '(4))
(let* ((beg (if (use-region-p)
(region-beginning)
  (if (org-before-first-heading-p) (point-min)
(save-excursion
  (org-with-limited-levels (org-back-to-heading t) 
(point))
   (end (if (use-region-p)
(region-end)
  (org-with-limited-levels (org-entry-end-position
   (inline-images (org--inline-image-overlays beg end)))
  (org-remove-inline-images beg end)
  (message "%d inline images display removed." (length inline-images
   ;; Display region selected inline images.
   ((use-region-p)
(message "Displaying inline images in region...")
(org-display-inline-images include-linked t (region-beginning) (region-end))
(message "Displaying inline images in region... done."))
   ;; Toggle display of inline image link at point.
   ((let ((context (org-element-context)))
  (and (memq (org-element-type context) '(link))
   (let ((beg (org-element-property :begin context))
 (end (org-element-property :end context)))
 (if (org--inline-image-overlays beg end)
 (progn
   (org-remove-inline-images beg end)
   (message "Display inline image at point removed."))
   (org-display-inline-images include-linked t beg end)
   (message "Displaying inline image at point ... done."))
 t
   ;; Display inline images under current section.
 

Re: [PATCH v2] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-15 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> You are almost there.
>>> Just run your code only when (lentgh> fulltable 26).
>>>
>>> Of course, 26 should be a defcustom rather than a hard-coded constant.
>>> And do the same for `org-fast-todo-selection'.
>>
>> Ok, I added defcustom option, and add cl-case condition on custom option
>> `org-use-fast-tag-selection'.
>
> I do not think that we need to care about the value of
> `org-use-fast-tag-selection'.  Instead, just
>
> 1. If the total number of tags does not exceed
>`org-fast-tag-selection-maximum-tags', display them all.
> 2. If the total number of tags is larger, just display all the bound
>tags + any extra tags, up to `org-fast-tag-selection-maximum-tags',
>and add a note in the tag selection buffer that more tags are not
>displayed.

I think we should consider the option `org-use-fast-tag-selection'.
Because it controls the behavior that whether auto assign short-key to
tags. Make condition decision based on this option is needed. I hope you
can reconsider this.

-- 

[ 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


[PATCH] add a function to only refresh inline images under current headline instead of global buffer

2023-05-14 Thread Christopher M. Miles

I found a lot of third-part Emacs packages refresh Org source block image 
result using the API function like this:

#+begin_src emacs-lisp
;; Automatically refresh inline images.
  (add-hook 'org-babel-after-execute-hook
(defun ob-dall-e--refresh-inline-images ()
  (when org-inline-image-overlays
(org-redisplay-inline-images
#+end_src

The `org-redisplay-inline-images' will refresh whole buffer inline
images. When the buffer is a big Org file, and not all inline images are
display already by default (still image file links under fold status).
Invoking `org-redisplay-inline-images' will cause Emacs suspend a long
time.

So I suggest to add an variant local function of
`org-redisplay-inline-images' which named
`org-redisplay-inline-images-under-headline' that only redisplay inline
images under current headline to solve the issue.

Here is the diff code prototype, Ihor, can you review it? If it's ok, I
will send patch update then.

#+begin_src diff
 (defun org-redisplay-inline-images ()
-  "Assure display of inline images and refresh them."
+  "Assure display of global all inline images in buffer and refresh them.
+
+NOTE: This function will refresh whole buffer inline images, if
+you only want to refresh inline images under headline, suggest to
+use `org-redisplay-inline-images-under-headline' in your hook or advice."
   (interactive)
   (org-toggle-inline-images)
   (unless org-inline-image-overlays
 (org-toggle-inline-images)))
 
+(defun org-redisplay-inline-images-under-headline ()
+  "Assure display of images under current headline and refresh them.
+This function is the suggested to be used in hook or advice."
+  (interactive)
+  (org-with-wide-buffer
+   (org-narrow-to-subtree)
+   ;; If has nested headlines, beg,end only from parent headline
+   ;; to first child headline which reference to upper
+   ;; let-binding `org-next-visible-heading'.
+   (org-display-inline-images
+nil nil
+(point-min) (progn (org-next-visible-heading 1) (point)
+
#+end_src

-- 

[ 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


[PATCH v2] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-14 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>>> #+begin_src emacs-lisp
>>>> (let ((bound-tags (seq-filter 'cdr temp-fulltable)))
>>>>   (if (length> bound-tags 0)
>>>>   bound-tags
>>>> (seq-take temp-fulltable 26)))
>>>> #+end_src
>>>
>>> This will unconditionally drop auto-labeled tags when user-bound tags
>>> exist, even if the total number of tags in buffer does not exceed 26.
>>
>> I try to read the source code of `org-fast-tag-selection', but the code is 
>> hard to read.
>
> Yeah. I agree. But we have what we have.
>
>> I don't know how to keep auto-labeled tags. Do you have any suggestions?
>
> You are almost there.
> Just run your code only when (lentgh> fulltable 26).
>
> Of course, 26 should be a defcustom rather than a hard-coded constant.
> And do the same for `org-fast-todo-selection'.

Ok, I added defcustom option, and add cl-case condition on custom option
`org-use-fast-tag-selection'.



0001-org-Improve-the-tags-fast-selection-performance.patch
Description: 

-- 

[ 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


Re: [PATCH] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-14 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> Sorry, wrong code, here is the correct code snippet:
>>
>> #+begin_src emacs-lisp
>> (let ((bound-tags (seq-filter 'cdr temp-fulltable)))
>>   (if (length> bound-tags 0)
>>   bound-tags
>> (seq-take temp-fulltable 26)))
>> #+end_src
>
> This will unconditionally drop auto-labeled tags when user-bound tags
> exist, even if the total number of tags in buffer does not exceed 26.

I try to read the source code of `org-fast-tag-selection', but the code is hard 
to read.
I don't know how to keep auto-labeled tags. Do you have any suggestions?


-- 

[ 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


Re: [PATCH] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-14 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> What about like this?
>>
>> #+begin_src emacs-lisp
>> (setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
>> (if (length> shortkeys 0)
>> bound-tags
>>   (seq-take fulltable 26)))
>>   char ?a cnt 0)
>> #+end_src
>
> What do you mean by "shortkeys"?

Sorry, wrong code, here is the correct code snippet:

#+begin_src emacs-lisp
(let ((bound-tags (seq-filter 'cdr temp-fulltable)))
  (if (length> bound-tags 0)
  bound-tags
(seq-take temp-fulltable 26)))
#+end_src

-- 

[ 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


Re: [PATCH] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-13 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> It would be great if you can come up with a patch.
>>> 1. Keeping tags with explicitly assigned key binding indeed makes sense
>>> 2. If we limit the number of displayed tags (on top of explicitly
>>>assigned), it should be a defcustom.
>>
>> Here is the patch.
>> -(setq tbl fulltable char ?a cnt 0)
>> +(setq tbl (seq-filter 'cdr fulltable) char ?a cnt 0)
>
> Thanks, but it will make the tag selection useless for people who did
> not customize explicit tag bindings.
>
> You should instead only filter when the number of tags exceeds some
> customized value.

What about like this?

#+begin_src emacs-lisp
(setq tbl (let ((bound-tags (seq-filter 'cdr fulltable)))
(if (length> shortkeys 0)
bound-tags
  (seq-take fulltable 26)))
  char ?a cnt 0)
#+end_src

-- 

[ 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


[PATCH] Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-13 Thread Christopher M. Miles

Ihor Radchenko  writes:

> stardiviner  writes:
>
>> I applied your diff with a testing. This indeed solved the performance
>> issue.
>> Will this be updated in Org-mode source code?
>> Also I come up with one thing, filter out tags which have shortcut
>> keybinding bound. Because user defined shortcut key defined tags are not
>> always on head of list.
>
> It would be great if you can come up with a patch.
> 1. Keeping tags with explicitly assigned key binding indeed makes sense
> 2. If we limit the number of displayed tags (on top of explicitly
>assigned), it should be a defcustom.

Here is the patch.



0001-org-Improve-the-tags-fast-selection-performance.patch
Description: 

-- 

[ 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


Re: Improve the performance of `org-set-tags-command` on large `org-tag-alist`

2023-05-13 Thread Christopher M. Miles

Ihor Radchenko  writes:

> stardiviner  writes:
>
>> I have a large `org-tag-alist` value that contains about ~7000 tags.
>> When I press [C-c C-q] `org-set-tags-command`. Emacs suspends a long time.
>
> Indeed. That's because `org-fast-tag-selection' tries to put all those
> 7k tags into tag selection window.
>
> We can probably limit the maximum number of tags in the quick selection
> window.
>
> Can you try the attached simple diff for `org-fast-tag-selection' and
> check if it is enough to solve the hang?
>
> diff --git a/lisp/org.el b/lisp/org.el
> index c148409d9..d745fd01e 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -11765,7 +11765,7 @@ (defun org-fast-tag-selection (current inherited 
> table  todo-table)
>   (org-fast-tag-insert "Current" current c-face "\n\n")
>   (org-fast-tag-show-exit exit-after-next)
>   (org-set-current-tags-overlay current ov-prefix)
> - (setq tbl fulltable char ?a cnt 0)
> + (setq tbl (seq-take fulltable 26) char ?a cnt 0)
>   (while (setq e (pop tbl))
> (cond
>  ((eq (car e) :startgroup)

I applied your diff with a testing. This indeed solved the performance issue.
Will this be updated in Org-mode source code?

-- 

[ 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


Re: BUG: org-cycle does not unfold some subtrees

2023-05-06 Thread Christopher M. Miles

I got similar result:


#+begin_example
Text content at position 33755:


There is an overlay here:
 From 33755 to 36387
  evaporatet
  invisibleorg-fold-outline
  isearch-open-invisible delete-overlay
  org-invisibleorg-fold-outline
  priority 5


There are text properties here:
  face org-level-2
  fontifiedt
  isearch-open-invisible org-fold-core--isearch-show
  isearch-open-invisible-temporary org-fold-core--isearch-show-temporary
  jinx--pendingt

#+end_example

#+begin_example
Text content at position 36387:


There are text properties here:
  fontifiedt
  isearch-open-invisible org-fold-core--isearch-show
  isearch-open-invisible-temporary org-fold-core--isearch-show-temporary

#+end_example

I confirmed I have NOT set `org-fold-core-style` to 'overlay.

Seems I have same reason with Michael.

Michael Dauer  writes:

> Got another observation:
> Text content at position 30248:
>
> There is an overlay here:
>  From 30248 to 30442
>   evaporatet
>   invisibleorg-fold-outline
>   isearch-open-invisible delete-overlay
>   org-invisibleorg-fold-outline
>   priority 5
>
> There are text properties here:
>   fontifiedt
>   isearch-open-invisible org-fold-core--isearch-show
>   isearch-open-invisible-temporary org-fold-core--isearch-show-temporary
>
> Am Sa., 6. Mai 2023 um 08:24 Uhr schrieb Ihor Radchenko :
>
>  "Christopher M. Miles"  writes:
>
>  > I meet an unfold-able headline now. Then I record a video to show this
>  > unfold-able headline. I executed command "describe-text-properties".
>
>  Please put the cursor right before the fold ("..."), execute M-x
>  describe-text-properties and share the properties description text.
>  You don't need video to share the property details buffer contents.
>
>  -- 
>  Ihor Radchenko // yantar92,
>  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>


-- 

[ 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


Re: BUG: org-cycle does not unfold some subtrees

2023-05-06 Thread Christopher M. Miles

"Christopher M. Miles"  writes:

> [[PGP Signed Part:Undecided]]
>
> I meet an unfold-able headline now. Then I record a video to show this
> unfold-able headline. I executed command "describe-text-properties".
> Afterwards, I closed the buffer, then re-open the file to show the
> headline can be expanded normally, and show the subtree content.
>
> Here is the uploaded video (P.S, I know video link is not a good way to
> archive information in mailing list, but this problem seems can't be
> text-described simply. Sorry about this.):
>
> https://upload.disroot.org/r/QNhW1xz0#X2or/2T7i7Kb7pHPxfAupRaEYJ28Sbp+2R6UDREnFic=

I recorded a new video which contains the Edebug process. Which shows
the `org-cycle' function internal status data. Ihor, hope this can help
you find the reason.

https://upload.disroot.org/r/khVnJgYV#vMBC3hiBUoPqBG2bgTEfJb44AUrGXVDuvpVGKv8Vw+w=

-- 

[ 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


[FEATURE Request] inherit headline directory for `org-attach' in `org-add-note' etc temp buffers

2023-05-05 Thread Christopher M. Miles

For example, I have Org content like this:

#+begin_src org
,* TODO Refrigerator
DEADLINE: <2023-04-06 Thu>
:PROPERTIES:
:ID:   e1824d15-35cb-4105-a617-5f7ecd6a1049
:END:
#+end_src

I press [C-c C-z] `org-add-note` to add logbook note. It will open a new
temporary buffer. I want to execute command [C-c C-a m] `org-attach-mv`
to attach a file. But it will prompt me for org-attach directory. I
think commands like `org-add-note`, `org-clock` add log, `org-todo`
change TODO state add log, etc should auto inherit this org-attach
directory. So that user can do `org-attach` in the temporary log buffer.

WDYT?

-- 

[ 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


Re: BUG: org-cycle does not unfold some subtrees

2023-05-05 Thread Christopher M. Miles

I meet an unfold-able headline now. Then I record a video to show this
unfold-able headline. I executed command "describe-text-properties".
Afterwards, I closed the buffer, then re-open the file to show the
headline can be expanded normally, and show the subtree content.

Here is the uploaded video (P.S, I know video link is not a good way to
archive information in mailing list, but this problem seems can't be
text-described simply. Sorry about this.):

https://upload.disroot.org/r/QNhW1xz0#X2or/2T7i7Kb7pHPxfAupRaEYJ28Sbp+2R6UDREnFic=

Ihor Radchenko  writes:

> Michael Dauer  writes:
>
>> This is with the cursor on the first asterisk:
>> Text content at position 299:
>>
>>
>> There are text properties here:
>>   display  [Show]
>>   face org-level-1
>>   fontifiedt
>
> Well. This shows nothing.
> I am more interested in text properties at the fold.
>
>> I could not test more positions because I accidentally cut it, and even an
>> undo fixed it. I would have to wait until it happens again.
>
> Sure. Let me know when you are able to get more info.


-- 

[ 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


Re: BUG: org-cycle does not unfold some subtrees

2023-05-05 Thread Christopher M. Miles

Michael Dauer  writes:

> Maybe I missed a known bug when doing the research. But all the other reports 
> describe different and
> reproducible behaviour.
>
> Sometimes (often) I cannot unfold a subtree. It then affects only one or more 
> subtrees while others in the
> same buffer or even the same branch still work. The only fix then is to 
> either cut and paste the affected
> branches, or to close and reopen the file.
>
> While quite frequent I have not achieved to reproduce the issue. It just 
> happens after a while of using
> multiple files navigating with search, tab from agenda, org-refile, and cycle.
>
> Based on my analyses it's not the cycle functions, but must come from broken 
> text attributes. Even
> (org-fold-core-region (point-min) (point-max) nil) does not unfold the 
> affected subtrees then. Assuming
> that (org-fold-core-region) is the only place where the folding and hiding 
> happens, I expect the problem
> there. But I understand too little about the emacs internals to debug this 
> function.
>
> I hope this helps to fix the issue.
>
> Org mode version 9.7-pre (release_9.6.4-327-gf81ba4

I got same problem many times. Usually I close buffer and re-open file again.
I can confirm this issue. I will provides some info help here too.

-- 

[ 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


Re: [EasyPG (epa)] Emacs can't save modified encrypted file

2023-05-05 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> - [X] Then I check out Emacs source code file "epg.el" & "epa.el" file
>>   git log. -> have not found obvious gpg command-line options related to
>>   the problem. One small possible commit might be
>>   "82388dff8ed006cecb65ea7a4afd8667ec44b5e3".
>
> One of the reddit comments mentioned that the newer gpg hangs when not
> provided input. If this is true, I notice that `epg-start-encrypt' first
> calls (epg-wait-for-status context '("BEGIN_SIGNING")) and only then
> sends the buffer string for encryption (process-send-string).

In order to connect this mail list thread with the Emacs bug report.
Put bug report link here:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63256

-- 

[ 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


Re: [EasyPG (epa)] Emacs can't save modified encrypted file

2023-05-05 Thread Christopher M. Miles

Ihor Radchenko  writes:

> Some more info: 
> https://old.reddit.com/r/emacs/comments/137r7j7/gnupg_241_encryption_issues_with_emacs_orgmode/

Indeed same problem as mine. Thanks Ihor

- [X] *downgrade* GnuPG from 2.4.1 -> 2.4.0 temporary get around the problem.

  #+begin_src sh
  brew info gnupg | grep "From:" | cut -d " " -f 2
  #+end_src

  #+RESULTS[(2023-05-05 14:19:54) 0e3dbbad14b66a4f05d2d70fb5cfd59db46f49bc]:
  : https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gnupg.rb

  #+begin_src sh
  
URL=https://raw.githubusercontent.com/Homebrew/homebrew-core/59edfe598541186430d49cc34f42671e849e2fc9/Formula/gnupg.rb
  wget $URL
  brew uninstall gnupg
  brew install -s gnupg.rb
  #+end_src

- [X] Check out GnuPG homepage changelog, Found new feature "ADSK: The 
Additional Decryption Subkey" for the problem gnupg version "2.4.1".
  After I executed bellowing command, -->> I still has problem.
  https://www.gnupg.org/blog/20230321-adsk.html

  #+begin_src sh
  gpg -K --with-subkey-fingerprint stardiviner
  #+end_src

  #+RESULTS[(2023-05-05 14:44:34) bc8e7497ce39ff0a8ae3fc45c332d64685e8da46]:
  : sec   rsa2048 2015-01-31 [SC]
  :   F09F650D7D674819892591401B5DF1C95AE89AC3
  : uid   [ultimate] stardiviner (numbch...@gmail.com) 

  : uid   [ultimate] stardiviner (Christopher Miles) 

  : uid   [ultimate] [jpeg image of size 3384]
  : ssb   rsa2048 2015-01-31 [E]
  :   32A8581A6E137ABD26DA2F570251FA6886EB6B77
  : 

  #+begin_src sh
  gpg --quick-add-adsk F09F650D7D674819892591401B5DF1C95AE89AC3 
32A8581A6E137ABD26DA2F570251FA6886EB6B77
  #+end_src

- [X] Then I check out Emacs source code file "epg.el" & "epa.el" file
  git log. -> have not found obvious gpg command-line options related to
  the problem. One small possible commit might be
  "82388dff8ed006cecb65ea7a4afd8667ec44b5e3".

-- 

[ 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


Re: [Uploaded Edebug video] Re: [EasyPG (epa)] Emacs can't save modified encrypted file

2023-05-03 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> Ok, I upload on Disroot website:
>>
>> https://upload.disroot.org/r/7skmXw7a#zt0jISsPuV0f3LkY9aRyz77X3iAOyD3cuue1Fbi9zy0=
>
> So, the hang happens on `epg-wait-for-status'.
> So, again, may you try to run the exact command line (including absence
> of input file) manually in terminal?
>
> Basically, `epg-wait-for-status' is looking at the output of gpg,
> waiting for "[GNUPG:] BEGIN_ENCRYPTION" and never gets that status from
> gpg. AFAIU.

I executed bellowing command in terminal without input file. (I added
aside comment using marker "|<--")

#+begin_src sh :eval no
$ gpg --no-tty --status-fd 1 --yes --enable-progress-filter --command-fd 0 
--pinentry-mode loopback --encrypt -r 1B5DF1C95AE89AC3 -r B8C4B8E547C32433

[GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
[GNUPG:] KEY_CONSIDERED 9BAA92BCCDDDB9EF3B36CB99B8C4B8E547C32433 0
[GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
gpg: 1B5DF1C95AE89AC3: skipped: public key already present   |<-- gpg wait for 
input and stopped here.
[GNUPG:] BEGIN_ENCRYPTION|<-- followed your 
hints, I input "[GNUPG:] BEGIN_ENCRYPTION" manually here.
hello|<-- I input text 
manually here.
[GNUPG:] PROGRESS stdin ? 0 0 B  |<-- gpg start to 
encrypting

=9I'iz^z=Ⱥ*pD>n̯dCj.:wD"zCy
  8$|
xMIiEXM{q2]"k1vx_$xIc3^L!L' $_уp
 T%QC a^i
WۄSuڅk?#\T}7
QhkwvUI#>^xNg{
#v/jͽrW[q9,W'%ϽVZ53BJGm_0VL`*vgT}[eQA:amRs?+z}6A/"b(?QU5*>ɨWQD$ih@ep^9<~[=5https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3


signature.asc
Description: PGP signature


Re: [EasyPG (epa)] Emacs can't save modified encrypted file

2023-05-03 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>   GPG_AGENT_INFO is not set
>>   /opt/homebrew/bin/gpg --no-tty --status-fd 1 --yes 
>> --enable-progress-filter --command-fd 0
>> --output /var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T/epg-outputxPZRrb 
>> --pinentry-mode
>> loopback --encrypt -r 1B5DF1C95AE89AC3 -r B8C4B8E547C32433
>>   [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
>>   [GNUPG:] KEY_CONSIDERED 9BAA92BCCDDDB9EF3B36CB99B8C4B8E547C32433 0
>>   [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
>>   #+end_example
>>
>> ...
>>   The encrypt command seems missing input file.
>
> Which is clearly wrong, AFAIU. I guess it is then time to report bug to
> Emacs? You may also try to find where the input file gets lost from the
> argument list.
>

Thanks for checking out, Ihor.

I tried to figure it out in the Edebug process, but don't know where
data is wrong. May you can check out my uploaded video.

I also will report bug to Emacs.

>> - [X] record screen record for edebug process (430M), then compress big 
>> recorded video (~170M).
>>
>>   I uploaded to here: https://file.io/5fvOAbW5DPi6
>
> No longer available.

I uploaded again, don't know why the file expired not available.

https://file.io/j17OelAJFVVi

-- 

[ 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


Re: ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively

2023-05-03 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> So currently ob-shell.el is async sending command into session buffer
>> without waiting for command to be finished.
>>
>> I checked out the ob-shell.el source code. I suppose this is the core
>> part of the problem. From intuitive view, session async evaluation
>> indeed should not wait for command to be finished. But still feel a
>> little weird.
>
> The core of the problem is in how Emacs comint is sending multiline
> input. My earlier example with M-x shell also demonstrates what is
> penning. comint.el basically simulates user input verbatim, as if you
> typed the whole thing symbol by symbol, including newlines.
>
> And it makes total sense as long as you are actually typing things
> interactively in the comint buffer.
>
> ob-shell :session in this case gets a bit weird. On one hand, it
> faithfully simulates interactive session. On the other hand, it does not
> feel fully interactive from user perspective, as you send a bunch of
> commands together within a single source block.
>
> One way to avoid the situations like with mpv could be packing the whole
> code block into script and then sending that script to comint session
> buffer. But then people who would like to actually switch to that buffer
> and work with it manually will get confused about what is going on
> there. (see `org-babel-switch-to-session' and
> `org-babel-switch-to-session-with-code').
>> If this :stdin interesting idea works, maybe other similar ideas will too.
>>
>> For examples:
>>
>> - Wrap command "mpv" with a shell function which disable accepting 
>> interactive input.
>
> Is there such a function? For all possible POSIX shells?
>
>> - Setting shell or environment variable in :prolog for source block to 
>> preventing interactive input.
>
> Again, do you know how to do this?

I tested with bash and wrap mpv into a function. The :prolog way is not
working too. Seems those workaround tries can't get around the
essential problem. I'm too naive

-- 

[ 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


Re: ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively

2023-05-03 Thread Christopher M. Miles

Ihor Radchenko  writes:

> Matt  writes:
>
>>  > Matt, maybe you have some ideas about this edge case?
>>
>> I have no other ideas within the current ob-shell implementation.  As for 
>> modifications, I have the following thoughts.
>>
>> First, how might we state the problem for this edge case?
>>
>> To me, it looks like, "How can the ob-shell :async option manage interactive 
>> input?" Do you agree
>> with this formulation? If not, how do you see it differently?
>
> It is not about :async per se. Rather about using :session.
>
> A simple reproducer is
>
> #+begin_src bash :session test
> mpv "/path/to/some/video"
> m_
> #+end_src
>
> Basically, when you send multiline command in comint buffer without
> waiting for each line to finish, the following line may be read by the
> running command if that command is interactive.
>
> It is similar to a situation when you run a normal terminal like
>
> $ mpv "..."
> 
> 
> $ m_ 
>

Indeed, this explaination give me more clear understanding of the problem.

So currently ob-shell.el is async sending command into session buffer
without waiting for command to be finished.

I checked out the ob-shell.el source code. I suppose this is the core
part of the problem. From intuitive view, session async evaluation
indeed should not wait for command to be finished. But still feel a
little weird.

#+begin_src emacs-lisp
(session; session evaluation
(if async
(progn
  (let ((uuid (org-id-uuid)))
(org-babel-comint-async-register
 session
 (current-buffer)
 "ob_comint_async_shell_\\(.+\\)_\\(.+\\)"
 'ob-shell-async-chunk-callback
 nil)
(org-babel-comint-async-delete-dangling-and-eval
session
  (insert (format ob-shell-async-indicator "start" uuid))
  (comint-send-input nil t)
  (insert (org-trim body))
  (comint-send-input nil t)
  (insert (format ob-shell-async-indicator "end" uuid))
  (comint-send-input nil t))
uuid))
  (mapconcat
   #'org-babel-sh-strip-weird-long-prompt
   (mapcar
#'org-trim
(butlast ; Remove eoe indicator
 (org-babel-comint-with-output
 (session org-babel-sh-eoe-output t body)
   (insert (org-trim body) "\n"
   org-babel-sh-eoe-indicator)
   (comint-send-input nil t))
 ;; Remove `org-babel-sh-eoe-indicator' output line.
 1))
   "\n")))
#+end_src

>> One thought is to update :async to work with the :stdin option so that
>> the block is run as a script. Currently, :stdin runs synchronously in
>> a separate shell. We might be able to grab the script's output and put
>> it into the session buffer. See how the following runs in a temporary
>> shell, regardless of the :session/:async options.
>
> Avoiding session altogether will indeed solve the problem, as :session
> is the place where the problem lies.
>
> Adding :stdin support is also an interesting idea, even out of scope of
> this discussion.

If this :stdin interesting idea works, maybe other similar ideas will too.

For examples:

- Wrap command "mpv" with a shell function which disable accepting interactive 
input.
- Setting shell or environment variable in :prolog for source block to 
preventing interactive input.

Anyway, glad to get more interesting ideas.

-- 

[ 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


Re: [EasyPG (epa)] Emacs can't save modified encrypted file

2023-05-03 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> Do you have any issues decrypting and encrypting files from command
>>> line? If no, what about from M-x shell? If yet no, what if you call gpg
>>> via `start-process'?
>>>
>>
>> - [X] test decrypt & encrypt in terminal with gpg command. -> works fine.
>>
>> - [X] test decrypt & encrypt in Emacs =[M-x shell]= with gpg command. -> 
>> works fine.
>> ...
>> - [X] test decrypt & encrypt in Emacs with ~start-process~ -> works fine
>
> Ok. The further step we can try is following what epg does.
> I am now looking into `epg--start' source code and I note
> `epg-debug' variable, which might provide some more info to think about.
> Also, note the `make-process' call in `epg--start' - you may try to run
> it manually, similar to `start-process' and check if it fails. (For me,
> :connection-type 'pipe part is a bit fishy - I recall there were some
> quirks related to it;
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44824 ... but it was the
> opposite to having 'pipe AFAIR).

Ok, I followed your suggestions, did following steps.

- [X] toggle option ~epg-debug~

  #+begin_src emacs-lisp
  (setq epg-debug t)
  #+end_src

  #+begin_example :file "*epg-debug*"
  GPG_AGENT_INFO is not set
  /opt/homebrew/bin/gpg --no-tty --status-fd 1 --yes --enable-progress-filter 
--command-fd 0 --output 
/var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T/epg-outputMMP3Zp 
--pinentry-mode loopback --decrypt -- 
/Users/stardiviner/.config/emacs/secrets/authinfo.gpg
  [GNUPG:] PROGRESS /Users/stardiviner/. ? 0 1204 B
  [GNUPG:] ENC_TO AEDA8A17BB08B786 1 0
  [GNUPG:] ENC_TO 0251FA6886EB6B77 1 0
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  [GNUPG:] KEY_CONSIDERED 9BAA92BCCDDDB9EF3B36CB99B8C4B8E547C32433 0
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  [GNUPG:] DECRYPTION_KEY 32A8581A6E137ABD26DA2F570251FA6886EB6B77 
F09F650D7D674819892591401B5DF1C95AE89AC3 u
  [GNUPG:] NO_SECKEY AEDA8A17BB08B786
  [GNUPG:] BEGIN_DECRYPTION
  [GNUPG:] DECRYPTION_INFO 2 7 0
  [GNUPG:] PROGRESS /Users/stardiviner/. ? 1204 1204 B
  [GNUPG:] PLAINTEXT 62 1682998161 
  [GNUPG:] DECRYPTION_OKAY
  [GNUPG:] GOODMDC
  [GNUPG:] END_DECRYPTION
  GPG_AGENT_INFO is not set
  /opt/homebrew/bin/gpg --no-tty --status-fd 1 --yes --enable-progress-filter 
--command-fd 0 --output 
/var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T/epg-outputE3zoeh 
--pinentry-mode loopback --encrypt -r 1B5DF1C95AE89AC3 -r B8C4B8E547C32433
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  [GNUPG:] KEY_CONSIDERED 9BAA92BCCDDDB9EF3B36CB99B8C4B8E547C32433 0
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  GPG_AGENT_INFO is not set
  /opt/homebrew/bin/gpg --no-tty --status-fd 1 --yes --enable-progress-filter 
--command-fd 0 --output 
/var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T/epg-outputxPZRrb 
--pinentry-mode loopback --encrypt -r 1B5DF1C95AE89AC3 -r B8C4B8E547C32433
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  [GNUPG:] KEY_CONSIDERED 9BAA92BCCDDDB9EF3B36CB99B8C4B8E547C32433 0
  [GNUPG:] KEY_CONSIDERED F09F650D7D674819892591401B5DF1C95AE89AC3 0
  #+end_example

- [X] test the debug output buffer printed full command in terminal. (remove 
=--output= option to see the output)

  #+begin_src sh :eval no
  gpg --no-tty --status-fd 1 --yes --enable-progress-filter --command-fd 0 
--pinentry-mode loopback --decrypt -- 
/Users/stardiviner/.config/emacs/secrets/authinfo.gpg
  # after input password, it decrypted success
  #+end_src

  The encrypt command seems missing input file.

  #+begin_src sh :eval no
  gpg --no-tty --status-fd 1 --yes --enable-progress-filter --command-fd 0 
--pinentry-mode loopback --encrypt -r 1B5DF1C95AE89AC3 -r B8C4B8E547C32433
  #+end_src

- [X] I look into ~epg--start~ source code. note the ~make-process~ call in 
~epg--start~ - you may try to
  run it manually, similar to ~start-process~ and check if it fails. (For me, 
~:connection-type 'pipe~
  part is a bit fishy.)

  #+begin_src emacs-lisp :eval no
  ;;; `epg-start-encrypt' -> `epg--start'
  (let ((context
 #s(epg-context :protocol OpenPGP :program "/opt/homebrew/bin/gpg" 
:home-directory nil :armor nil :textmode nil :include-certs nil 
:cipher-algorithm nil :digest-algorithm nil :compress-algorithm nil 
:passphrase-callback (epa-file-passphrase-callback-function . 
"/Users/stardiviner/.config/emacs/secrets/authinfo.gpg") :progress-callback 
(epa-progress-callback-function . "Encrypting 
/Users/stardiviner/.config/emacs/secrets/authinfo.gpg") :edit-callback nil 
:signers nil :sender nil :sig-notations nil :process nil :output-file 
"/var/folders/ym/f3v5_yk1

Re: [EasyPG (epa)] Emacs can't save modified encrypted file

2023-05-02 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I downgrade gnupg, then the problem solved. But the downgrade version is
>> very old (gnupg@2.4.1 -> gnupg@2.2.41). I suspend problem is somewhere
>> else, like Emacs interaction with GnuPG process.
>
> Do you have any issues decrypting and encrypting files from command
> line? If no, what about from M-x shell? If yet no, what if you call gpg
> via `start-process'?
>

- [X] test decrypt & encrypt in terminal with gpg command. -> works fine.

- [X] test decrypt & encrypt in Emacs =[M-x shell]= with gpg command. -> works 
fine.

  #+begin_example
  bash-5.2$ bash-5.2$ 
  bash-5.2$ pwd 
  /Users/stardiviner/.config/emacs/secrets
  bash-5.2$ gpg -d authinfo.gpg > authinfo 
  gpg: encrypted with rsa2048 key, ID 0251FA6886EB6B77, created 2015-01-31
"stardiviner (numbch...@gmail.com) "
  gpg: encrypted with rsa2048 key, ID AEDA8A17BB08B786, created 2012-03-02
"Christopher Miles (stardiviner, numbchild) "
  gpg: using "F09F650D7D674819892591401B5DF1C95AE89AC3" as default secret key 
for signing
  bash-5.2$ ls 
  accounts.json.gpg authinfoauthinfo.gpg
  bash-5.2$ 
  #+end_example

- [X] test decrypt & encrypt in Emacs with ~start-process~ -> works fine

  #+begin_src emacs-lisp :dir "~/.config/emacs/secrets/" :results output
  (let ((output-buffer "*gnupg-decrypt*"))
(pwd)
(when (get-buffer output-buffer)
  (with-current-buffer (get-buffer output-buffer)
(erase-buffer)))
(start-process
 "gnupg-testing"
 output-buffer
 "gpg"
 "--decrypt" "authinfo.gpg"
 ;; ">" "authinfo"
 )
(sleep-for 2)
(print
 (with-current-buffer (get-buffer output-buffer)
   (buffer-substring-no-properties (point-min) (point-max)
  #+end_src

>> 4. I press =[C-g]= to quit got following stacktrace:
>>
>> #+begin_example
>> Debugger entered--Lisp error: (quit)
>>   accept-process-output(# 1)
>
> This certainly looks like gpg itself is waiting for something and Emacs
> is waiting for gpg...
>
>> When I save modified "=~/.config/emacs/secrets/authinfo.gpg=", got prompt:
>>
>> #+begin_example
>> Untrusted key AEDA8A17BB08B786 Christopher Miles (stardiviner, numbchild) 
>> .  Use anyway? (y or n)
>> #+end_example
>
>> If I input "n" for prompt:
>>
>> #+begin_example
>> Debugger entered--Lisp error: (file-error "Opening output file" "Encrypt 
>> failed" "Unusable public key: B8C4B8E547C32433 (key not tru...")
>
> This reminds me of 
> https://orgmode.org/list/2023-01-22t18-32...@devnull.karl-voit.at
> CC-ing Karl as he might be interested to join this discussion.
>

His error indeed same with mine. I have read email and check my private
key. Here is my private key info:

Check out my private key info:

#+begin_src sh
# gpg -K
gpg --list-secret-keys --verbose --with-subkey-fingerprints
#+end_src

#+RESULTS[(2023-05-03 01:41:09) 80ae7b09060704481af2e01ae6f6086262d4a05c]:
#+begin_example
/Users/stardiviner/.gnupg/pubring.kbx
-
sec   rsa2048 2015-01-31 [SC]
  F09F650D7D674819892591401B5DF1C95AE89AC3
uid   [ultimate] stardiviner (numbch...@gmail.com) 
uid   [ultimate] stardiviner (Christopher Miles) 
uid   [ultimate] [jpeg image of size 3384]
ssb   rsa2048 2015-01-31 [E]
  32A8581A6E137ABD26DA2F570251FA6886EB6B77

#+end_example

>> - [X] find bellowing two key ID belongs where
>>
>> Untrusted key "AEDA8A17BB08B786" ---> fingerprint 
>> "0DEF7425E79FE2E0090B424BAEDA8A17BB08B786" --> my old key
>> ((invalid-recipient (reason . 10) (requested . "B8C4B8E547C32433"))) --> 
>> "F09F650D7D674819892591401B5DF1C95AE89AC3" --> my current new gnupg key
>>
>> Question: I don't know why my current gnupg key and old gnupg key are 
>> together.
>>
>> Here is my Emacs EasyPG (epa) config:
>>
>> #+begin_src emacs-lisp
>> (use-package epa
>>   ;; force Emacs to use its own internal password prompt instead of an 
>> external
>>   ;; pinentry program.
>>   :preface (setenv "GPG_AGENT_INFO" nil)
>
> I do not use this setting on my side and simply stick to gtk password
> prompt.
>

I check my pinentry on macOS. Found package "pinentry-mac" installed by
Homebrew. Then I use it as pinentry-program in "gpg-agent.conf" config file.

Then I tested by remove upper (setenv "GPG_AGENT_INFO" nil) line.
Restart Emacs still same problem.

Then I disable my "epa" config,

[CLOSED] [ANSWER] Re: a temporary workaround solution using another language like "python"

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I check out ob-screen, it indeed can be used in my situation, thanks for 
>> suggestion.
>
> Also, you can try --no-terminal cmd switch for mpv. It will suppress
> terminal interaction, AFAIU.

Indeed, this option solved the problem real neat.
I'm surprised by your knowledge and digging problem skill.
I have to say a big TANKS to you. THANKS, THANKS, THANKS. Hahaha

-- 

[ 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


Re: [SUGGESTION] Re: [PATCH] org-crypt-decrypt-entry: Apply initial visibility upon decryption

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> The current CPU report indeed not contains heavy org-crypt. Because my
>> epa get problem. When I edit a GnuPG encrypted "encrypt.org.gpg", it
>> suspend on epa waiting for process to finished. It never ends unless I
>> press [C-g] to quit it.
>
> Which looks like gpg tried to display password prompt is some awkward
> place (like in bash sub-process under Emacs) and is forever waiting for
> your input.
>
> I have (setenv "DISPLAY" ":0.0") in my init.el to let graphical
> dialogues know how to popup from under Emacs process.

I'm under macOS system. the result of (getenv "DISPLAY") is
"ssh-askpass". This is weird...

I will dig deeper about this issue, update here later.

-- 

[ 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


Re: ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> My first version property "EVAL" inline src block indeed don't using
>> :async and :session. It can play video file.
>>
>> But I found it will block [Tab] org-cycle expand headline. I don't want
>> Emacs to be suspended. So I added :async change.
>
> For my use case, I simply use C-c C-a o to open the attachment or put a
> file link inside and use C-c C-o on the heading.

Indeed, Usually, your suggestion keybinding should be enough. I
originally add this hook for auto play background music or video MV etc.
I might think another method to do this auto action. For example auto
find first media file link and auto open it when match one specific condition.

-- 

[ 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


Re: [SOLUTION] a temporary workaround solution using another language like "python"

2023-05-01 Thread Christopher M. Miles

Max Nikulin  writes:

> On 01/05/2023 20:08, Christopher M. Miles wrote:
>> I use another language "python" to replace "sh" to play video now. It 
>> successes.
>> :EVAL: src_python{import os; video_file = "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4";
>> os.system("mpv \"%s\" " %(video_file))}
>> It's not as convenient as shell command directly but at least it works.
>> Seems the sh inline source block can't be used to play video using "mpv"
>> (I also tested other video player commands like "mplayer", "iina" etc).
>
> For interactive application you may try ob-screen. I find its name confusing.

I check out ob-screen, it indeed can be used in my situation, thanks for 
suggestion.

-- 

[ 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


Re: ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I might consider to use another language like python instead of sh to
>> execute command to play video to get around this issue. I will update
>> here if I success.
>
> All you need to do is getting rid of :async and :session.
> Just use :results none + "&" at the end of mpv command.
> Non-session blocks will not suffer from this problem.

My first version property "EVAL" inline src block indeed don't using
:async and :session. It can play video file.

But I found it will block [Tab] org-cycle expand headline. I don't want
Emacs to be suspended. So I added :async change.

Now I use python `os.system()` to invoke shell command works fine.

Here is my current version:

(defcustom org-property-eval-keyword "EVAL"
  "A property keyword for evaluate code."
  :type 'string
  :safe #'stringp
  :group 'org)

(add-to-list 'org-default-properties org-property-eval-keyword)

(defun org-property-eval-on-cycle-expand ( state)
  "Evaluate Org inline source block in property value on headline cycle expand."
  (when (memq state '(children subtree))
(if-let ((inline-src-block (org-entry-get nil org-property-eval-keyword 
nil)))
(with-temp-buffer
  (insert inline-src-block)
  (goto-char (point-min))
  (let* ((context (org-element-context))
 (lang (org-element-property :language context))
 (type (org-element-type context))
 (src-block-info (org-babel-get-src-block-info nil context)))
(when (eq type 'inline-src-block)
  (org-babel-execute-src-block
   nil src-block-info
   (pcase lang
 ("sh" `((:session . ,(make-temp-name " *ob-sh-inline-async 
(sh) ")) (:async . "yes") (:results . "silent")))
 ("shell" `((:session . ,(make-temp-name " *ob-sh-inline-async 
(shell) ")) (:async . "yes") (:results . "silent")))
 ("bash" `((:session . ,(make-temp-name " *ob-sh-inline-async 
(bash) ")) (:async . "yes") (:results . "silent")))
 ("zsh" `((:session . ,(make-temp-name " *ob-sh-inline-async 
(zsh) ")) (:async . "yes") (:results . "silent")))
 ("python" `((:session . ,(make-temp-name 
"ob-python-inline-async ")) (:async . "yes") (:results . "silent")))
 (_ '((:results . "none")))

(add-hook 'org-cycle-hook #'org-property-eval-on-cycle-expand)

(defvar org-property-eval-templates
  '("src_sh{mpg123 \"path/to/music.mp3\"}"
"src_python{import os; os.system(\"mpv 'path/to/video.mp4' \")}"))
(org-completing-read-property-construct-function "EVAL" 
org-property-eval-templates)
(add-to-list 'org-property-set-functions-alist '("EVAL" . 
org-completing-read-property_eval))

-- 

[ 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


Re: [SUGGESTION] Re: [PATCH] org-crypt-decrypt-entry: Apply initial visibility upon decryption

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>>>> May you elaborate what performance issues you are experiencing?
>>>>
>>>> My performance issue is a large Org file about 2M size on saving. I will
>>>> reproduce and generate profiler report for more detailed data and update
>>>> in this thread.
>>>
>>> Please save the report using M-x profiler-report-write-profile - it will
>>> produce Elisp data that can be re-opened and examined directly.
>>
>> I attached CPU and Memory report in attachments.
>
> This CPU report is not just for saving. You did M-x (vectico), `undo',
> `org-clock-in', and `save-buffer'. `save-buffer' took no time. And
> everything took less than one second.
>
> Are you sure that it is the correct profile?

The current CPU report indeed not contains heavy org-crypt. Because my
epa get problem. When I edit a GnuPG encrypted "encrypt.org.gpg", it
suspend on epa waiting for process to finished. It never ends unless I
press [C-g] to quit it. So I can't reproduce the Org file contains
org-crypt headlines saving profiler report.

Sorry that I have not mentioned this actual background reason. I indeed
did a profiler report before (about 3 months ago), and the profiler
report use lot of time on org-crypt invocation. Hmm, maybe problem gone
as time scrolls.

I will mark this as task in my Org Agenda, and take time to profiler
report again, make sure org-crypt is heavy, then update here.

Regards,

-- 

[ 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


[SOLUTION] a temporary workaround solution using another language like "python"

2023-05-01 Thread Christopher M. Miles

I use another language "python" to replace "sh" to play video now. It successes.

Here is my example:

#+begin_src org
,* 《枕刀歌》
:PROPERTIES:
:DATE: [2021-05-13 Thu 20:09]
:Douban:   https://movie.douban.com/subject/35350794/
:DIR:  枕刀歌
:EVAL: src_python{import os; video_file = "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"; 
os.system("mpv \"%s\" " %(video_file))} 
:END:

#+end_src

It's not as convenient as shell command directly but at least it works.
Seems the sh inline source block can't be used to play video using "mpv"
(I also tested other video player commands like "mplayer", "iina" etc).

So this python solution is a workaround.

-- 

[ 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


Re: ob-shell sessions will send final echo '...' as input key sequence when previous command reads input interactively

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> So, it looks to me like mpv is somehow trying to interpret "echo" commands 
>>> the
>>> ob-shell is sending after "mpv " is executed:
>> ...
>> Don't know ob-shell which part did your said "echo" commands. I don't
>> know where to dig this issue. Hope you can help. Thanks for your
>> reproducing problem and dive in.
>
> The underlying issue lies within how comint works + the fact that mpv
> reads key input from terminal.
>
> Try the following:
>
> 1. emacs -Q
> 2. M-x shell
> 3. cd /path/to/your/video 
> 4. Copy the following into kill ring
> -
> mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"
> m_
> -
> 5. (in the shell buffer): C-y 
> 6. Observe mpv playing no sound and video
> 7. Press m_ to restore video and sound.
>

I reproduced same now. Thanks for your guide.

> I am not sure if we can do much about this though.
> We run async shell commands in sessions using
>
> (insert (format ob-shell-async-indicator "start" uuid))
> (comint-send-input nil t)
> (insert (org-trim body))
> (comint-send-input nil t)
> (insert (format ob-shell-async-indicator "end" uuid))
> (comint-send-input nil t)
>
> which sends
>
> "echo ''
> 
> echo '...'"
>
> to comint terminal session.
>
> The last echo '...' in this case is interpreted as key input by mpv -
> symbol by symbol.
>
> The only way I know how to work around this is a giant one-liner like
> echo ''; ; echo '...'
>

I understand the process now, it is wrapped by ob-shell-async-indicator echo 
command.

> However, (1) ";" may not work in some shells; (2)  may
> contain multiple lines, leading to the same issue.

I tested it (using ";") now, not working.

I might consider to use another language like python instead of sh to
execute command to play video to get around this issue. I will update
here if I success.

-- 

[ 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


Re: [SUGGESTION] Re: [PATCH] org-crypt-decrypt-entry: Apply initial visibility upon decryption

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> We should certainly not attempt decryption on  by default - it may
>>> be annoying when you actually do not want to decrypt anything, just
>>> look inside.
>>
>> You're right, I have not consider enough.
>
> Of course, you can still use `org-cycle-hook' if you want this behaviour
> in your personal setup.
>
>>> May you elaborate what performance issues you are experiencing?
>>
>> My performance issue is a large Org file about 2M size on saving. I will
>> reproduce and generate profiler report for more detailed data and update
>> in this thread.
>
> Please save the report using M-x profiler-report-write-profile - it will
> produce Elisp data that can be re-opened and examined directly.

I attached CPU and Memory report in attachments.



cpu.report
Description: CPU Report


memory.report
Description: Memory Report


-- 

[ 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


Re: [SUGGESTION] Re: [PATCH] org-crypt-decrypt-entry: Apply initial visibility upon decryption

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I'm also try to improve this file to improve large Org buffer saving 
>> performance.
>
> org-encrypt already caches the encrypted text and takes basically no
> time for the repeated encryption, as long the text to be encrypted is 
> unchanged.
>
>> I have some ideas:
>>
>> - auto encrypt buffer on buffer save hook (currently mechanism, your patch 
>> improved it)
>
> Sorry, but my patch has nothing to do with save hook. It only changes 
> decryption.
>
>> - auto decrypt on org-cycle expand headline if current headline is 
>> encrypted. e.g. on `org-cycle-hook`
>
> I am not sure how it has anything to do with performance.
> You can already use C-c C-r (or M-x org-reveal) to decrypt entry at
> point.
> We should certainly not attempt decryption on  by default - it may
> be annoying when you actually do not want to decrypt anything, just
> look inside.

You're right, I have not consider enough.

>
>> - auto encrypt ONLY current fold action on headline scope if has crypt key 
>> specified. e.g. on `org-cycle-hook`
>
> That might be possible, but I often do not want my encrypted
> sub-headings being encrypted while I re-structure and re-fold my file.
>
> May you elaborate what performance issues you are experiencing?

My performance issue is a large Org file about 2M size on saving. I will
reproduce and generate profiler report for more detailed data and update
in this thread.

-- 

[ 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


Re: [Need Help] Error to evaluate "mpv" command in inline src block

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>>> But I failed to execute mpv command:
>>>>
>>>> #+begin_src org
>>>> Test src_sh{mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"}
>>>> #+end_src
>>>
>>> May you elaborate what you mean by "failed"?
>>
>> The "failed" means the MPV video player window does not show up, no video, 
>> no audio.
>
> Interesting. I tried harder to reproduce following your steps.
> Now, I used a video file with CJK name:
>
> * 《枕刀歌》
> :PROPERTIES:
> :DATE: [2021-05-13 Thu 20:09]
> :Douban:   https://movie.douban.com/subject/35350794/
> :DIR:  鸟瞰古
> :EVAL: src_sh{mpv "鸟瞰古/【人文纪录片】鸟瞰古代中国.Ancient.China.from.Above P1 
> 鸟瞰古代中国.Ancient.China.from.Above.S01flv"}
> :END:
>
> And I can reproduce - mpv windows shows up, but no video and no sound.
> Then, I tried to open the same video in usual way... and still no sound
> - until I press "m" to unmute.
>
> So, it looks to me like mpv is somehow trying to interpret "echo" commands the
> ob-shell is sending after "mpv " is executed:
>
> ob_comint_async_shell_start_d1cc7563-be0c-4ed0-a4c2-d1b545333983
> org_babel_sh_prompt> =[input] No key binding found for key 'c'.
> ...
> [input] No key binding found for key '''.
> [input] No key binding found for key 'b'.
> ...
> [input] No key binding found for key '''.
>
> These "No key binding found statements" a likely from "echo" commands
> attempted to be sent to the terminal.

Do you think this issue is from Emacs shell part or mpv part?

-- 

[ 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


Re: [Need Help] Error to evaluate "mpv" command in inline src block

2023-05-01 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>>> But I failed to execute mpv command:
>>>>
>>>> #+begin_src org
>>>> Test src_sh{mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"}
>>>> #+end_src
>>>
>>> May you elaborate what you mean by "failed"?
>>
>> The "failed" means the MPV video player window does not show up, no video, 
>> no audio.
>
> Interesting. I tried harder to reproduce following your steps.
> Now, I used a video file with CJK name:
>
> * 《枕刀歌》
> :PROPERTIES:
> :DATE: [2021-05-13 Thu 20:09]
> :Douban:   https://movie.douban.com/subject/35350794/
> :DIR:  鸟瞰古
> :EVAL: src_sh{mpv "鸟瞰古/【人文纪录片】鸟瞰古代中国.Ancient.China.from.Above P1 
> 鸟瞰古代中国.Ancient.China.from.Above.S01flv"}
> :END:
>
> And I can reproduce - mpv windows shows up, but no video and no sound.
> Then, I tried to open the same video in usual way... and still no sound
> - until I press "m" to unmute.
>
> So, it looks to me like mpv is somehow trying to interpret "echo" commands the
> ob-shell is sending after "mpv " is executed:
>
> ob_comint_async_shell_start_d1cc7563-be0c-4ed0-a4c2-d1b545333983
> org_babel_sh_prompt> =[input] No key binding found for key 'c'.
> ...
> [input] No key binding found for key '''.
> [input] No key binding found for key 'b'.
> ...
> [input] No key binding found for key '''.
>
> These "No key binding found statements" a likely from "echo" commands
> attempted to be sent to the terminal.

I have similar output in session buffer too. Here is the output in my session 
buffer.

When I press Tab key to expand upper headline. I check the inline src block 
session buffer, here is the output:

#+begin_example
bash-5.2$ bash-5.2$ PROMPT_COMMAND=;PS1="org_babel_sh_prompt> ";PS2=
org_babel_sh_prompt> echo 
'ob_comint_async_shell_start_d1cc7563-be0c-4ed0-a4c2-d1b545333983'
mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"
echo 'ob_comint_async_shell_end_d1cc7563-be0c-4ed0-a4c2-d1b545333983'
ob_comint_async_shell_start_d1cc7563-be0c-4ed0-a4c2-d1b545333983
org_babel_sh_prompt> =[input] No key binding found for key 'c'.
[input] No key binding found for key 'h'.
[input] No key binding found for key '''.
[input] No key binding found for key 'b'.
[input] No key binding found for key 'c'.
[input] No key binding found for key 'n'.
[input] No key binding found for key 'a'.
[input] No key binding found for key 'y'.
[input] No key binding found for key 'n'.
[input] No key binding found for key 'c'.
[input] No key binding found for key 'h'.
[input] No key binding found for key 'n'.
[input] No key binding found for key 'c'.
[input] No key binding found for key 'c'.
[input] No key binding found for key '-'.
[input] No key binding found for key 'b'.
[input] No key binding found for key 'c'.
[input] No key binding found for key '-'.
[input] No key binding found for key '-'.
[input] No key binding found for key 'a'.
[input] No key binding found for key 'c'.
[input] No key binding found for key '-'.
[input] No key binding found for key 'b'.
[input] No key binding found for key '''.

Resuming playback. This behavior can be disabled with --no-resume-playback.

 Video --vid=1 (*) (h264 1920x1080 25.000fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
AO: [coreaudio] 48000Hz stereo 2ch floatp
Mute: yes



  C-c C-c>
Saving state.

Exiting... (Quit)
org_babel_sh_prompt> echo $SHELL 
/bin/zsh
org_babel_sh_prompt> 
#+end_example


I also try to add "sleep 1;" command before "mpv ..." command to delay
mpv executing. Still not success.

Don't know ob-shell which part did your said "echo" commands. I don't
know where to dig this issue. Hope you can help. Thanks for your
reproducing problem and dive in.

-- 

[ 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


[SUGGESTION] Re: [PATCH] org-crypt-decrypt-entry: Apply initial visibility upon decryption

2023-04-30 Thread Christopher M. Miles

Thanks Ihor for improve this file.

I'm also try to improve this file to improve large Org buffer saving 
performance.

I have some ideas:

- auto encrypt buffer on buffer save hook (currently mechanism, your patch 
improved it)
- auto decrypt on org-cycle expand headline if current headline is encrypted. 
e.g. on `org-cycle-hook`
- auto encrypt ONLY current fold action on headline scope if has crypt key 
specified. e.g. on `org-cycle-hook`

-- 

[ 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


Re: [Need Help] Error to evaluate "mpv" command in inline src block

2023-04-30 Thread Christopher M. Miles

Ihor Radchenko  writes:

> stardiviner  writes:
>
>> I have Emacs Org mode config like bellowing to auto evaluate inline src
>> block when Org headline cycle expanded.
>> ...
>> Here is the testing Org content:
>> ...
>>
>> When I press Tab key to expand upper headline. I check the inline src block
>> session buffer, here is the output:
>>
>> #+begin_example
>> bash-5.2$ bash-5.2$ PROMPT_COMMAND=;PS1="org_babel_sh_prompt> ";PS2=
>> org_babel_sh_prompt> echo
>> 'ob_comint_async_shell_start_d1cc7563-be0c-4ed0-a4c2-d1b545333983'
>> mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"
>> echo 'ob_comint_async_shell_end_d1cc7563-be0c-4ed0-a4c2-d1b545333983'
>> ob_comint_async_shell_start_d1cc7563-be0c-4ed0-a4c2-d1b545333983
>> org_babel_sh_prompt> =[input] No key binding found for key 'c'.
>> ...
>> Resuming playback. This behavior can be disabled with --no-resume-playback.
>>
>>  Video --vid=1 (*) (h264 1920x1080 25.000fps)
>>  (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
>> AO: [coreaudio] 48000Hz stereo 2ch floatp
>> Mute: yes
>>
>>
>>
>>   C-c C-c>
>> Saving state.
>>
>> Exiting... (Quit)
>> org_babel_sh_prompt> echo $SHELL
>> /bin/zsh
>> org_babel_sh_prompt>
>> #+end_example
>
> It looks like mpv command is running.
>

Yes, check out the output from the sh session buffer, we can confirm mpv is 
executed.
But seems got weird error.

>> ...
>> But I failed to execute mpv command:
>>
>> #+begin_src org
>> Test src_sh{mpv "枕刀歌/《枕刀歌》SE05 江海阔 歌谣哼唱.mp4"}
>> #+end_src
>
> May you elaborate what you mean by "failed"?

The "failed" means the MPV video player window does not show up, no video, no 
audio.

-- 

[ 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


Re: [Need Help] Error to evaluate "mpv" command in inline src block

2023-04-30 Thread Christopher M. Miles

Ruijie Yu  writes:

> Try putting "cat" there.  I suspect something is fed into the stdin of
> the process.

Can you explain in detailed? Don't know how to put command "cat" in my 
situation.

-- 

[ 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


Re: Emacs and org mode in aws

2023-04-16 Thread Christopher M. Miles

Naresh Gurbuxani  writes:

> In my Amazon Web Service account, I can launch emacs from the terminal. 
> Nearly all emacs features
> work well. But I miss the ability to view graphs created by code blocks in 
> org mode. Have other
> members found a solution?
>

I don't know whether AWS supports SSH X11 Forwarding. But you can check
out this feature to get Linux desktop forwarding view as for Emacs
graphics.

-- 

[ 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


[SOLVED] Re: How to change working directory in ob-matlab source block?

2023-04-12 Thread Christopher M. Miles

stardiviner  writes:

> Is there friend know Emacs Org mode and Matlab here?
>
> I try to save Matlab plot into image file in another path instead of current 
> working directory. Like
> bellowing code:
>
> #+headers: :var cwd=(expand-file-name "data/images/" (file-name-directory 
> (buffer-file-name)))
> #+headers: :prologue "eval(sprintf("cd '%s'", cwd))"
> #+headers: :epilogue "saveas(gcf,'matlab-plot-demo2.png'); close(gcf);"
> #+begin_src matlab :results graphics file link :dir "data/images" :file 
> "matlab-plot-demo2.png" :session
> "*MATLAB*"
> bar([1 11 7 8 2 2 9 3 6])
> #+end_src
>
> #+RESULTS[(2023-04-13 00:09:01) c5fc0d36b27e75610664ee69ae618649637e45d9]:
> [[file:data/images/matlab-plot-demo2.png]]
>
> But Matlab command "cd" does not work correctly in upper code method.
>

I find out the solution. The "cd" command used as a function then pass
in path string as argument. It works fine. So I adopt source block like
this:

#+headers: :var cwd=(expand-file-name "data/images/" (file-name-directory 
(buffer-file-name)))
#+headers: :prologue "cd(cwd)"
#+begin_src matlab :session "*MATLAB*" :results output
% eval(sprintf("cd '%s'", cwd))
% eval(sprintf("cd('%s')", cwd))
% cd(cwd)

% returns the path to the current working directory.
pwd
#+end_src

#+RESULTS[(2023-04-13 13:20:27) 0c1259b084fc93f95d7c60c9c748a0630bf4391d]:
#+begin_example
cd(cwd)
cwd='/Users/stardiviner/Org/Wiki/Computer Technology/Programming/Emacs/Emacs 
Packages/Org mode/data/images/';
% eval(sprintf("cd '%s'", cwd))
% eval(sprintf("cd('%s')", cwd))
% cd(cwd)
% returns the path to the current working directory.
pwd

ans =

'/Users/stardiviner/Org/Wiki/Computer Technology/Programming/Emacs/Emacs 
Packages/Org mode/data/images'
#+end_example

Really tricky for me. Hope helpful for some user.

-- 

[ 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


Re: Remove "shell" as a supported Babel language within ob-shell.el

2023-03-24 Thread Christopher M. Miles

At first, thanks for this long parsing and explanation.

Matt  writes:

>  > Matt m...@excalamus.com> writes:
>  >
>  > > Is there a reason you're using "shell" instead of one of the shells 
> listed in `org-babel-shell-names'?
>
> I'm still curious why you're using "shell".  I want to know if it's something 
> you're using for a specific reason.  There's no wrong answer!
>
> I ask because I have an agenda: as far as I can tell, "shell" as a Babel 
> language is a historical accident.  
>
> #+begin_longwinded_explanation
> Originally, ob-shell.el was called ob-sh.el.  The main function was called 
> `org-babel-execute:sh' and only /usr/bin/env sh was supported.  Over time it 
> became clear that to support other shells, the "sh" name shouldn't be used 
> for the package or the main function.  That is, 'sh' refers to a specific 
> binary and, if other binaries such as bash, dash, csh, etc. were to be 
> supported, it would be misleading for the Babel language to refer to a 
> specific shell, 'sh'.  So, the terminology was changed to something more 
> general, "shell".  The package was renamed to "ob-shell.el", the "namespace" 
> updated to "shell" (for example, `org-babel-execute:shell'), and the package 
> load call changed from (sh . t) to (shell . t).  This officially happened 
> with Org 8.2 (ORG-NEWS noted the change in commit 
> 1a9adcb6d34bcbdff45445c827ed99dbf0b8, Tue Jan 21 09:52:31 2014).  I think 
> this gave people the (understandable) impression that "shell" was a valid 
> Babel language, in addition to those listed in `org-babel-shell-names'.  
>
> And this is where the accident happened: "shell" as a Babel language only 
> **happens**to work.  The Babel framework looks for a function prototype like 
> "org-babel-execute:".  When ob-sh.el was changed to ob-shell.el, 
> the function `org-babel-execute:sh' became `org-babel-execute:shell'.   A 
> call like follows is perfectly legal as far as the Babel framework is 
> concerned:
>
> #+begin_src shell
> echo "hello, world"
> #+end_src
>
> When such a block is run, Babel looks for a function called 
> `org-babel-execute:shell'. Running the
> block prior to Org 8.2 should have failed because no 
> `org-babel-execute:shell' function existed. The
> name change happened to source Fri Dec 13 09:52:05 2013 in commit
> 7a6c0e35415c4a173d101336029262f3a09abb91. After the name change, the function 
> existed and a block
> using "shell" would execute!

Yes, I originally use "sh" too. But at some time point, I saw an article
somewhere, then I switched to "shell". I forget the specific reason
already.

> The "shell" language specifier, as far as I can tell, was never really 
> intentionally supported.
> Instead, it just happened to work. It happened to work because, as far back 
> as the first
> org-babel-sh.el commit, the process buffer is created using the `shell' 
> function. I don't know the
> history of `shell', but presently the documentation says,
>
> Program used comes from variable ‘explicit-shell-file-name’,
>  or (if that is nil) from the ESHELL environment variable,
>  or (if that is nil) from ‘shell-file-name’.
>
> That is, the `shell' command falls back to `shell-file-name'. I assume that 
> `shell' has always had
> that, or a similar, fallback. The `shell-file-name' is a direct path to an 
> executable. This means
> that when "shell" is used for the language, `shell-file-name' is called and 
> **any** startup script,
> such as .bash_profile or .bashrc, is called. The prompt could be set to 
> **anything** and Emacs will
> never know, and can never know, what the prompt is without the user 
> explicitly informing Emacs.
>
> Aside from the code change which allowed "shell" to work, "official" support 
> of "shell" comes from
> Org manual commit 9d072ad67517875069f913315d762c9bb1e9c3ec, Sun Dec 17 
> 11:06:05 2017 (for example,
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/doc/org-manual.org?id=f7aa8c19f5170dbf09538686fb569f9b60acbd6c#n18410).
> This appears unconnected with the code change. The addition to the manual 
> happened 4 years after the
> code name change and none of the commit messages around the time of code 
> change suggest that "shell"
> was intended to work as a language. In fact, I found this email from Eric 
> Schulte (creator of Babel
> and maintainer at the time of the code change) which suggests that "shell" is 
> in fact not supported
> or intented as a language 
> (https://lists.gnu.org/archive/html/emacs-orgmode/2013-12/msg00294.html):
>
> In response to the statement,
>
> "a coworker used "#+BEGIN_SRC shell" where he should have written 
> "#+BEGIN_SRC sh"
>
> Eric says,
>
> "[The suggested work around] would protect against this particular error"
>
> #+end_longwinded_explanation
>
> Regardless of whether "shell" was intended to work as a Babel language, the 
> fact remains that it
> does work and that it's been advertised in the manual (at least) for 6 years. 
> What are the pros and
> cons of 

Re: [RFC] Limit inline image width by default (was: feature request: easy embedding of images)

2023-03-23 Thread Christopher M. Miles

This is an acceptable solution for large width image. I propose this RFC too.

-- 

[ 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


Re: [SUGGESTION] ob-shell async result output should not contains shell prompt

2023-03-23 Thread Christopher M. Miles

Matt  writes:

>   On Wed, 22 Mar 2023 23:25:50 -0400  Christopher M. Miles  wrote --- 
>  > 
>  > The ob-shell async result output contains the shell prompt. I think it
>  > should not be captured.
>  > 
>  > #+begin_src shell :session "test2" :async t
>  > sleep 30
>  > echo "hello, world"
>  > #+end_src
>  > 
>  > #+RESULTS[(2023-03-23 11:19:22) 461ed5de684f6e619890709175ec73e80b67b2d6]:
>  > : bash-5.2$ hello, world
>
> Thanks for reporting this.
>
> Try using for the babel language whatever shell the variable 
> `shell-file-name' gives.  For example, if `shell-file-name' is /bin/bash, do 
> this:
>
> #+begin_src bash :session "test2" :async t
> sleep 1
> echo "hello, world"
> #+end_src
>
> Is there a reason you're using "shell" instead of one of the shells listed in 
> `org-babel-shell-names'?

Using language identities like bellowing:

#+begin_src sh :session "*ob-shell*" :async t
sleep 30
echo "hello, world"
#+end_src

#+RESULTS[(2023-03-23 19:14:12) dd777a237986481833c08eb5eceac717576eddb7]:
: org_babel_sh_prompt> hello, world

#+begin_src bash :session "*ob-shell-bash*" :async t
sleep 30
echo "hello, world"
#+end_src

#+RESULTS[(2023-03-23 19:14:15) 23f9ad130f7a1268e21821c6baaea2b057c70d3e]:
: org_babel_sh_prompt> hello, world

#+begin_src zsh :session "*ob-shell-zsh*" :async t
sleep 30
echo "hello, world"
#+end_src

#+RESULTS[(2023-03-23 19:14:17) 2bb44d96c2e482a90c5a89bdde0b64d0319663a1]:
: % 

 
:  
: % 

 
:  
: hello, world
: % 

 
:  

Still got a prompt. Is this intended? I think the output should be kept clean 
because the result
output might be used as input for other source blocks as data.

Maybe error in my Org babel settings? Bellowing is my system and variable 
values:

#+begin_src emacs-lisp
system-type
#+end_src

#+RESULTS[(2023-03-23 19:27:13) 7df8395169a77d83cb6a5a6efc2223d412813efa]:
: darwin

#+begin_src emacs-lisp
shell-file-name
#+end_src

#+RESULTS[(2023-03-23 19:26:33) e6fed18a9a543dd6320385ee715d9ee68b464a04]:
: /opt/homebrew/bin/bash

#+begin_src emacs-lisp
org-babel-sh-prompt
#+end_src

#+RESULTS[(2023-03-23 19:30:12) f6efc29dba5be2171eba0a25abec19908fb1c6be]:
: org_babel_sh_prompt> 

#+begin_src emacs-lisp
org-babel-shell-names
#+end_src

#+RESULTS[(2023-03-23 19:27:27) 360d6d35db3eb48deb664349eed34b7541923ca2]:
| sh | bash | zsh | fish | csh | ash | dash | ksh | mksh | posh |

#+begin_src emacs-lisp :results pp
org-babel-shell-set-prompt-commands
#+end_src

#+RESULTS[(2023-03-23 19:27:44) 910fbbafc6fea4a1846f5a31f8b7dd102eca4928]:
: (("fish" . "function fish_prompt\necho \"%s\"\nend")
:  ("csh" . "set prompt=\"%s\"\nset prompt2=\"\"")
:  ("posh" . "function prompt { \"%s\" }")
:  (t . "PROMPT_COMMAND=;PS1=\"%s\";PS2="))

-- 

[ 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


[CANCELED] Re: [BUG] org-capture got file userlock error when I capture on second time.

2023-03-22 Thread Christopher M. Miles

Ihor Radchenko  writes:

> stardiviner  writes:
>
>> When I org-capture from elfeed-entry buffer (I defined custom functions to
>> extract elfeed entry buffer content) in the second time and later, the
>> bellowing error raised up. The first-time capture is fine.
>>
>> Here is the error backtrace:
>> #+begin_example
>> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>>   expand-file-name(nil)
>>   userlock--check-content-unchanged("~/Org/Tasks/Tasks.org")
>
> This looks like some interaction between Org setting `buffer-file-name'
> to nil in *Capture* buffer and Emacs' file locking machinery. Maybe.
> Maybe Emacs bug. I have no better ideas.
>
> I also see nothing wrong we do on Org side.

First, Ihor, I need to thank you. With your hints. I try to figure out
what things might get involved between Org setting `buffer-file-name'
and *Capture* buffer.

1. I try to set `org-capture-mode-hook`, `org-mode-hook' etc to nil.

2. Use bug-hunter to bisect my emacs config, the first start, the
   problem does not occurred, this is weird, even I tried many times.

3. Then I use comment to bisect my init.el, try to figure out the
   reason. Still not found. And the problem not occurred.

4. I start Emacs again with original config. Now the problem gone. I
   restart Emacs many times, problem still not occurred. Weird.

-- 

[ 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


[SUGGESTION] ob-shell async result output should not contains shell prompt

2023-03-22 Thread Christopher M. Miles

The ob-shell async result output contains the shell prompt. I think it
should not be captured.

#+begin_src shell :session "test2" :async t
sleep 30
echo "hello, world"
#+end_src

#+RESULTS[(2023-03-23 11:19:22) 461ed5de684f6e619890709175ec73e80b67b2d6]:
: bash-5.2$ hello, world

-- 

[ 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


Re: [SUGGESTION] separate ob-clojure.el into Clojure part ob-clojure.el and ClojureScript part ob-clojurescript.el

2023-03-20 Thread Christopher M. Miles

Ihor Radchenko  writes:

> Daniel Kraus  writes:
>
>>> The only downside is that people might need to
>>> (require 'ob-clojurescript)
>>> I am thinking if ob-core.el should try to automatically guess the
>>> correct library to be loaded.
>>
>> We could just (require 'ob-clojurescript) inside ob-clojure.el ?!
>
> Sure. Though it will go against the goal for not loading everything in
> Org on startup. (Currently, Org startup is too slow for some people).
>
> In any case, I was mostly thinking aloud in a broader context, not just
> ob-clojure.el. For ob-clojure, either way is fine.

Yeah, loading only when necessary is great for startup. For non-expert
user, it's helpful, because they don't know configure it well.

-- 

[ 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


Re: [SUGGESTION] separate ob-clojure.el into Clojure part ob-clojure.el and ClojureScript part ob-clojurescript.el

2023-03-20 Thread Christopher M. Miles

Ihor Radchenko  writes:

> stardiviner  writes:
>
>> For now, ob-clojure.el contains lot of code for ClojureScript. Only some
>> code has same functionality. Like CIDER backend. In the future,
>> ClojureScript part code will increase and different. So I suggest
>> separate them into two source code files.
>>
>> WDYT?
>
> The only downside is that people might need to
> (require 'ob-clojurescript)
> I am thinking if ob-core.el should try to automatically guess the
> correct library to be loaded.

I think this is an good idea. It let user don't need to load
ob-.el before user really need it. The ob-core.el will
automatically load  related libraries. For now I have to configure
ob-.el like bellowing to defer loading:

#+begin_src emacs-lisp
(use-package ob-clojure
  :custom (org-babel-clojurescript-backend 'cider)
  :commands (org-babel-execute:clojurescript)
  :config
  (add-to-list 'org-babel-load-languages '(clojurescript . t))
  (org-babel-do-load-languages 'org-babel-load-languages 
org-babel-load-languages)
  ;; let `ob-clojurescript' babel source blocks allow evaluation.
  (add-to-list 'org-babel-default-header-args:clojurescript '(:eval . "yes"))
  (add-to-list 'org-babel-default-header-args:clojurescript '(:noweb . "yes")))
#+end_src

The duplicated part code bellowing is repeated for every :

#+begin_src emacs-lisp
(add-to-list 'org-babel-load-languages '(clojurescript . t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)
#+end_src

>
> Otherwise, I am neutral towards this split.
>
> Up to Daniel.


-- 

[ 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


[SUGGESTION] separate ob-clojure.el into Clojure part ob-clojure.el and ClojureScript part ob-clojurescript.el

2023-03-20 Thread Christopher M. Miles
For now, ob-clojure.el contains lot of code for ClojureScript. Only some
code has same functionality. Like CIDER backend. In the future,
ClojureScript part code will increase and different. So I suggest
separate them into two source code files.

WDYT?

-- 

[ 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


Re: [BUG] Shift-up/down move the cursor to end of timestamp

2022-12-02 Thread Christopher M. Miles

I meet this bug too.

-- 

[ 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


Re: OrgModeClockingXBar - see a task when you clock in in your bar and not only

2022-11-14 Thread Christopher M. Miles

mag_dex  writes:

> Dear All,
>
> I designed a hack to see your clocked-in task on your bar (and not only).
>
> The hack is composed of a few elements, Emacs code that adds hooks for 
> clock-in and clock-out and a code
> for Xbar.
>
> I have been using this for 2 years, and it's pretty robust. I didn't have 
> time to share it before.
>
> The code is not perfect, if you quit your Emacs, without clocking-out the 
> content of the file will not be
> changed so you will not see any update on the bar (at least not till next 
> clocking-in or -out)
>
> https://github.com/mmagnus/OrgModeClockingXBar
>
> Magnus

Thanks for sharing, this is what I needed.

-- 

[ 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


Re: Tutorials on creating pdfs with org-babel and sqlite

2022-11-12 Thread Christopher M. Miles

You can check out 
http://www.howardism.org/Technical/Emacs/literate-database.html

This is very great.

Jan Ulrich Hasecke  writes:

> [[PGP Signed Part:Undecided]]
> Dear all,
>
> I am doing my first steps to do some database publishing with org-babel
> and sqlite. So far quite successful, but I am still very new to this, so
> I would appreciate if you can recommend a tutorial on this. I am mostly
> interested in publishing use cases. Has anybody wrote a book or a report
> with org-mode, org-babel and sqlite? What options I have to format the
> output so that I can export it to pdf via pandoc and context?
>
> TIA
> juh
>
>
>
> [[End of PGP Signed Part]]


-- 

[ 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


Re: CI tests

2022-11-06 Thread Christopher M. Miles

Christian Köstlin  writes:

> Dear org-mode users,
>
>
> at the moment I am trying to enable as much of the org-mode testsuite
> on the ci server (see https://builds.sr.ht/~bzg for the latest
> testruns).
>
> From time to time some tests fail, because the time when e.g. a
> timestamp is written to the buffer is different to when the timestamp
> is calculated in the test (the minute just flips there).
>
> The buildserver already stumbled over:
> - test-org/org-log-done
> - test-org-capture/fill-template
> but I think there might be more problems like that.
>
> Did you also see that when running the tests locally?
>
> Kind regards,
> Christian

Feedback: I have not seen those two tests failed on my local running.

-- 

[ 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


Re: Auto detect ob-clojure backend (was: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list)

2022-10-30 Thread Christopher M. Miles

Daniel Kraus  writes:

> Ihor Radchenko  writes:
>
>> Daniel Kraus  writes:
>>
>>> +(defcustom org-babel-clojure-backend (cond
>>> +  ((executable-find "bb") 'babashka)
>>> +  ((executable-find "nbb") 'nbb)
>>> +  ((featurep 'cider) 'cider)
>>> +  ((featurep 'inf-clojure) 
>>> 'inf-clojure)
>>> +  ((featurep 'slime) 'slime)
>>> + (t nil))
>>
>> What if users have, say, cider installed and also babashka executable?
>> Will it be expected to use babashka?
>
> Yes. The only thing that makes me slightly hesitant is that e.g.
> someone doesn't have `bb` installed. Executes clojure source blocks
> which are then evaluated in, let's say cider.
> Then they install `bb` and the next time they start Emacs, the same
> source block on re-evaluation would be executed with babashka.
>
> I think this is still the best out of the box experience as it
> "just works" for most users without having to customise something
> and if they want it fixed, they can pin it to a certain backend.
>
> What's your opinion?
>
> Cheers,
>   Daniel

I vote for use Clojure CLI like bb as default backend. Keeping defcustom
option for user to setting default backend is fine.

-- 

[ 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


[CLOSED] Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list

2022-10-29 Thread Christopher M. Miles

Daniel Kraus  writes:

> Hi
>
> Ihor Radchenko  writes:
>> "Christopher M. Miles"  writes:
>>> Any review comments about this patch?
>> I have sent the following comment shortly after your followup:
>
> I even made another post after that, suggesting that the if condition
> is not even needed. Simply always quoting seems to work and is also the
> way it's done in `ob-lisp.el`.
> See https://list.orgmode.org/orgmode/874jvp9wsg@kraus.my/
>
> This simple patch is also already installed. Can you test if that works for 
> you?
>
> And in case you missed it, I made another reply for you bug report
> about inline comments.
> Check https://list.orgmode.org/orgmode/878rl1a1e0@kraus.my/
>
> Thanks,
>   Daniel

Indeed, your solution is better. Sorry that I have not realized your
patch. Thanks for notify me again. Closed this thread now.

-- 

[ 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


[CLOSED] Re: [BUG] Org mode treat tags as links

2022-10-29 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> I defined a custom link type "video:".
>>
>> And when I added tag "video" in tags like bellowing:
>>
>> #+begin_src org
>> * headline 1 :tag1:video:hello
>> #+end_src
>
> Note that this particular example actually contains a link. Because you
> forgot the closing ":" in the tags.
>
> I guess you meant
>
> * headline 1 :tag1:video:hello:
>

Yes, I miss typed the last colon. Thanks for understanding correctly.

>> It caused the tag ":video:" parsed and recognized as link. Here is the 
>> screenshot:
>> I suppose the link parsing need to be improved.
>
> This is fontification error.
> You can examine the parser state by issuing M-: (org-element-context) with
> point at the "link". It is correctly recognized as a headline with no link.
>
> The error is due to limitations in our current implementation of
> fontification. Will be fixed in
> https://orgmode.org/list/87ee7c9quk.fsf@localhost

I see, Thanks for notifying.

-- 

[ 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


Re: [PATCH] Fix ob-clojure handling source block variable's value is a org-mode table or list

2022-10-28 Thread Christopher M. Miles

Any review comments about this patch?

"Christopher M. Miles"  writes:

> [[PGP Signed Part:Undecided]]
>
> I bellowing example:
>
> #+begin_src org
> ,#+NAME: ob-clojure-table-test
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+NAME: ob-clojure-table-test-2
> | a | b | c |
> |---+---+---|
> | 1 | 2 | 3 |
>
> ,#+begin_src clojure :var kk=ob-clojure-table-test :var 
> kk2=ob-clojure-table-test-2 :results output
> (println kk2)
> (println kk)
> ,#+end_src
>
> #+end_src
>
> Without this patch, it will report error "class java.lang.ClassCastException" 
> from CIDER.
>
> This patch added if condition to handle this table, list type data.
>
> From 948e8c1ff2c9ba1d9c0fe26f9bdaa096bef80a9d Mon Sep 17 00:00:00 2001
> From: stardiviner 
> Date: Sat, 9 Apr 2022 21:14:22 +0800
> Subject: [PATCH] ob-clojure.el: Fix header argument :var binding passed table
>  or list data
>
> * lisp/ob-clojure.el (org-babel-expand-body:clojure): Add if condition
> to handle source block :var passed org-mode table or list data for
> clojure let-binding to avoid java.lang.ClassCastException.
> ---
>  lisp/ob-clojure.el | 25 ++---
>  1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
> index 5a44b6487..e6614b2d9 100644
> --- a/lisp/ob-clojure.el
> +++ b/lisp/ob-clojure.el
> @@ -101,13 +101,24 @@
>(and (cdr (assq :ns params)) (format "(ns %s)\n" ns))
>;; Variables binding.
>(if (null vars) (org-trim body)
> -(format "(let [%s]\n%s)"
> -(mapconcat
> - (lambda (var)
> -   (format "%S %S" (car var) (cdr var)))
> - vars
> - "\n  ")
> -body))
> +   ;; variable's value is a list from org-mode passed table 
> or list.
> +(if (listp (cdr (car vars)))
> +   (format "(let [%s]\n%s)"
> +   (mapconcat
> +(lambda (var)
> +  (format "%S '%S" (car var) (cadr var)))
> +vars
> +"\n  ")
> +   body)
> + ;; else, the header argument variable's value is not a 
> list.
> + (format "(let [%s]\n%s)"
> + (mapconcat
> +  (lambda (var)
> +(format "%S %S" (car var) (cdr var)))
> +  vars
> +  "\n  ")
> + body)
> + ))
>  (if (or (member "code" result-params)
>   (member "pp" result-params))
>   (format "(clojure.pprint/pprint (do %s))" body)
> -- 
> 2.35.1
>
> [5. text/x-patch; 
> 0001-ob-clojure.el-Fix-header-argument-var-binding-passed.patch]...


-- 

[ 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


[BUG] Org mode treat tags as links

2022-10-28 Thread Christopher M. Miles

I defined a custom link type "video:".

And when I added tag "video" in tags like bellowing:

#+begin_src org
* headline 1 :tag1:video:hello
#+end_src

It caused the tag ":video:" parsed and recognized as link. Here is the 
screenshot:


I suppose the link parsing need to be improved.

-- 

[ 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


Re: [ANN] The 2022 Emacs User Survey is now open!

2022-10-26 Thread Christopher M. Miles

Completed

Timothy  writes:

> Hi All,
>
> I’m thrilled to announce that the Emacs User Survey 2022 is now open to
> responses. It is my hope that this may help emacs-devel, Emacs package
> maintainers, and the wider Emacs community develop a better understanding of
> how people experience Emacs on a day-to-day basis.
>
> 
>
> The survey will be open from October 24th to November 30th.
>
> This time there are /no/ non-free Javascript or user-tracking caveats as this
> features a bespoke survey framework written from scratch for the Emacs User
> Survey to support a pure HTML-forms + CSS approach with server-side rendering
> .
>
> See the [FAQ] for more information on the survey itself.
>
> It would be fantastic for this to be shared as far and wide as possible, to 
> get
> responses from a large swathe of the community. If you can share this with 
> Emacs
> communities you are a part of, as well as any friends or colleagues that use
> Emacs, that would be much appreciated.
>
> We can look forward to a discussion of the (preliminary) results in EmacsConf:
> .
>
> All the best,
> Timothy


-- 

[ 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


Re: [PATCH v3] New: auto display inline images under subtree when `org-cycle'.

2022-10-25 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> Sure. Can you please send the final version of the patch and the working
>>> tests?
>>
>> I separated code patch and test into two patches. You can apply selectively.
>
> Sorry, I was not very clear.
> I meant to remove that patch that fails due to noninteractive and leave
> the rest.
>

Updated, I deleted testing and marked as TODO.

>>  doc/org-manual.org|   6 +++
>>  etc/ORG-NEWS  |   7 
>>  lisp/org-cycle.el |  38 +-
>>  lisp/org-keys.el  |   2 +-
>>  lisp/org.el   |  21 ++
>>  .../images/Org mode logo mono-color.png   | Bin 0 -> 7523 bytes
>
> The image should belong to the test patch.

Updated.

From 4cdf69001832bcc180e7c607c15c44c484954c82 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Tue, 4 Oct 2022 12:36:32 +0800
Subject: [PATCH 1/2] org.el: Support auto display inline images when cycling

* lisp/org.el (org-toggle-inline-images): Support region.
(org-display-inline-images): Fix refresh argument logic.
(org-remove-inline-images): Support region.

* lisp/org-keys.el (org-toggle-inline-images): Update arguments.

* lisp/org-cycle.el (org-cycle-inline-images-display): Add new option to
control whether auto display inline images when cycling.
(org-cycle-display-inline-images): Add new hook function to auto display
inline images when cycling.
(org-cycle-hook): Add `org-cycle-display-inline-images' into cycling
hook by default.

* doc/org-manual.org (Exporting):
* etc/ORG-NEWS: Document the new option.
---
 doc/org-manual.org |  6 ++
 etc/ORG-NEWS   |  7 +++
 lisp/org-cycle.el  | 38 --
 lisp/org-keys.el   |  2 +-
 lisp/org.el| 21 +
 5 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ad584d7a5..18a050069 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11489,6 +11489,12 @@ command:
   - When set to nil, try to get the width from an =#+ATTR.*= keyword
 and fall back on the original width if none is found.
 
+
+#+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
+visible inline images under subtree will be displayed automatically.
+
 ** Captions
 :PROPERTIES:
 :DESCRIPTION: Describe tables, images...
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c18c03725..d87b49bd3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -307,6 +307,13 @@ to pass the contents of a named code block as a string argument.
 The new property =ORG-IMAGE-ACTUAL-WIDTH= can override the global
 variable ~org-image-actual-width~ value for inline images display width.
 
+*** Outline cycling can now include inline image visibility
+
+New ~org-cycle-hook~ function ~org-cycle-display-inline-images~ for
+auto-displaying inline images in the visible parts of the subtree.
+This behavior is controlled by new custom option
+~org-cycle-inline-images-display~.
+
 *** New ~org-babel-tangle-finished-hook~ hook run at the very end of ~org-babel-tangle~
 
 This provides a proper counterpart to ~org-babel-pre-tangle-hook~, as
diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el
index c1caa3fdc..14388caaf 100644
--- a/lisp/org-cycle.el
+++ b/lisp/org-cycle.el
@@ -208,8 +208,9 @@ the values `folded', `children', or `subtree'."
   :type 'hook)
 
 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
-		   org-cycle-show-empty-lines
-		   org-cycle-optimize-window-after-visibility-change)
+org-cycle-show-empty-lines
+org-cycle-optimize-window-after-visibility-change
+org-cycle-display-inline-images)
   "Hook that is run after `org-cycle' has changed the buffer visibility.
 The function(s) in this hook must accept a single argument which indicates
 the new state that was set by the most recent `org-cycle' command.  The
@@ -229,6 +230,13 @@ normal outline commands like `show-all', but not with the cycling commands."
   :group 'org-cycle
   :type 'boolean)
 
+(defcustom org-cycle-inline-images-display nil
+  "Non-nil means auto display inline images under subtree when cycling."
+  :group 'org-startup
+  :group 'org-cycle
+  :package-version '(Org . "9.6")
+  :type 'boolean)
+
 (defvar org-cycle-tab-first-hook nil
   "Hook for functions to attach themselves to TAB.
 See `org-ctrl-c-ctrl-c-hook' for more information.
@@ -775,6 +783,32 @@ STATE should be one of the symbols listed in the docstring of
 		   "Subtree is archived and stays closed.  Use \
 `\\[org-cycle-force-archived]' to cycle it anyway."

Re: [PATCH 2-v4] New: auto display inline images under subtree when `org-cycle'.

2022-10-23 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> Whether can this patch be merged at first, put the test in future to
>> finish? In recent days, I still have not figured out this image overlays
>> test.
>
> Sure. Can you please send the final version of the patch and the working
> tests?

I separated code patch and test into two patches. You can apply selectively.

From 2beacea9082e7eddd5db426cd180ea42ebb46656 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Tue, 4 Oct 2022 12:36:32 +0800
Subject: [PATCH 1/2] org.el: Support auto display inline images when cycling

* lisp/org.el (org-toggle-inline-images): Support region.
(org-display-inline-images): Fix refresh argument logic.
(org-remove-inline-images): Support region.

* lisp/org-keys.el (org-toggle-inline-images): Update arguments.

* lisp/org-cycle.el (org-cycle-inline-images-display): Add new option to
control whether auto display inline images when cycling.
(org-cycle-display-inline-images): Add new hook function to auto display
inline images when cycling.
(org-cycle-hook): Add `org-cycle-display-inline-images' into cycling
hook by default.

* doc/org-manual.org (Exporting):
* etc/ORG-NEWS: Document the new option.
---
 doc/org-manual.org|   6 +++
 etc/ORG-NEWS  |   7 
 lisp/org-cycle.el |  38 +-
 lisp/org-keys.el  |   2 +-
 lisp/org.el   |  21 ++
 .../images/Org mode logo mono-color.png   | Bin 0 -> 7523 bytes
 6 files changed, 63 insertions(+), 11 deletions(-)
 create mode 100755 testing/examples/images/Org mode logo mono-color.png

diff --git a/doc/org-manual.org b/doc/org-manual.org
index ad584d7a5..18a050069 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -11489,6 +11489,12 @@ command:
   - When set to nil, try to get the width from an =#+ATTR.*= keyword
 and fall back on the original width if none is found.
 
+
+#+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
+visible inline images under subtree will be displayed automatically.
+
 ** Captions
 :PROPERTIES:
 :DESCRIPTION: Describe tables, images...
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c18c03725..d87b49bd3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -307,6 +307,13 @@ to pass the contents of a named code block as a string argument.
 The new property =ORG-IMAGE-ACTUAL-WIDTH= can override the global
 variable ~org-image-actual-width~ value for inline images display width.
 
+*** Outline cycling can now include inline image visibility
+
+New ~org-cycle-hook~ function ~org-cycle-display-inline-images~ for
+auto-displaying inline images in the visible parts of the subtree.
+This behavior is controlled by new custom option
+~org-cycle-inline-images-display~.
+
 *** New ~org-babel-tangle-finished-hook~ hook run at the very end of ~org-babel-tangle~
 
 This provides a proper counterpart to ~org-babel-pre-tangle-hook~, as
diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el
index c1caa3fdc..14388caaf 100644
--- a/lisp/org-cycle.el
+++ b/lisp/org-cycle.el
@@ -208,8 +208,9 @@ the values `folded', `children', or `subtree'."
   :type 'hook)
 
 (defcustom org-cycle-hook '(org-cycle-hide-archived-subtrees
-		   org-cycle-show-empty-lines
-		   org-cycle-optimize-window-after-visibility-change)
+org-cycle-show-empty-lines
+org-cycle-optimize-window-after-visibility-change
+org-cycle-display-inline-images)
   "Hook that is run after `org-cycle' has changed the buffer visibility.
 The function(s) in this hook must accept a single argument which indicates
 the new state that was set by the most recent `org-cycle' command.  The
@@ -229,6 +230,13 @@ normal outline commands like `show-all', but not with the cycling commands."
   :group 'org-cycle
   :type 'boolean)
 
+(defcustom org-cycle-inline-images-display nil
+  "Non-nil means auto display inline images under subtree when cycling."
+  :group 'org-startup
+  :group 'org-cycle
+  :package-version '(Org . "9.6")
+  :type 'boolean)
+
 (defvar org-cycle-tab-first-hook nil
   "Hook for functions to attach themselves to TAB.
 See `org-ctrl-c-ctrl-c-hook' for more information.
@@ -775,6 +783,32 @@ STATE should be one of the symbols listed in the docstring of
 		   "Subtree is archived and stays closed.  Use \
 `\\[org-cycle-force-archived]' to cycle it anyway."))
 
+(defun org-cycle-display-inline-images (state)
+  "Auto display inline images under subtree when cycling.
+It works when `org-cycle-inline-images-display' is non-nil."
+  (when org-cycle-inline-images-display
+(pcase state
+  ('children
+   (org-with-

Re: [PATCH 2-v4] New: auto display inline images under subtree when `org-cycle'.

2022-10-21 Thread Christopher M. Miles

Whether can this patch be merged at first, put the test in future to
finish? In recent days, I still have not figured out this image overlays
test.

"Christopher M. Miles"  writes:

> [[PGP Signed Part:Undecided]]
>
> Ihor Radchenko  writes:
>
>> "Christopher M. Miles"  writes:
>>
>>>> I think that the best we can do in this situation is mocking
>>>> `create-image' in batch mode to return non-nil using `cl-letf'.
>>>
>>> I checked the `create-image' in image.el source code, don't know how to
>>> mocking this. I have no experience and idea about this. I also searched
>>> org testing. Have not found similar situations.
>>>
>>> If you have idea how to write this test, I suggest pass this word to
>>> you. What do you think?
>>
>> I imagine something like
>>
>> ;; Mock `create-image' to work noninteractively.
>> (cl-letf (((symbol-function 'create-image)
>> (lambda ( _)
>>   `(image :type "dummy" :data "dummy"
>>   )
>
> After wrapped your cl-letf redefining function binding. Still failed on test.
>
> Here is the new test code:
>
> #+begin_src emacs-lisp
> (ert-deftest test-org-fold/org-fold-display-inline-images ()
>   "Test inline images displaying when cycling."
>   ;; Mock `create-image' to work noninteractively.
>   (cl-letf (((symbol-function 'create-image)
>(lambda ( _) `(image :type "dummy" :data "dummy"
> (let* ((org-cycle-inline-images-display t)
>(images-dir (expand-file-name "examples/images/" org-test-dir))
>(org-logo-image (expand-file-name "Org mode logo mono-color.png" 
> images-dir)))
>   ;; `org-cycle' -(state)-> `'children' display child inline images.
>   (org-test-with-temp-text
>(format "* Heading 1
> [[file:%s]]
> " org-logo-image)
>(org-overview)
>;; (org-cycle)
>;; (org-cycle-internal-local)
>;; (org-cycle-display-inline-images 'children)
>(org-fold-show-children)
>(run-hook-with-args 'org-cycle-hook 'children)
>(org-next-link)
>(should org-inline-image-overlays)
>(should (overlays-at (point)))
>(org-toggle-inline-images)
>(should-not (overlays-at (point
>   
>   ;; `org-cycle' -(state)-> `'subtree' display subtrees inline images.
>   (org-test-with-temp-text
>(format "* Heading 1
> [[file:%s]]
> ** Subheading 1
> [[file:%s]]
> ** Subheading 2
> [[file:%s]]" org-logo-image org-logo-image org-logo-image)
>(org-overview)
>;; (org-cycle)
>;; (org-cycle)
>;; (org-cycle-internal-global)
>(org-fold-show-subtree)
>(run-hook-with-args 'org-cycle-hook 'subtree)
>(org-next-link)
>(org-next-link)
>;; (should org-inline-image-overlays)
>(should (overlays-at (point)))
>(org-toggle-inline-images)
>(should-not (overlays-at (point
>   
>   ;; `org-cycle' -(state)-> `'folded' remove inline image overlays.
>   (org-test-with-temp-text
>(format "* Heading 1
> [[file:%s]]
> ** Subheading 1
> [[file:%s]]
> ** Subheading 2
> [[file:%s]]" org-logo-image org-logo-image org-logo-image)
>(org-overview)
>(org-show-subtree)
>(org-fold-subtree t)
>(run-hook-with-args 'org-cycle-hook 'folded)
>(should (null org-inline-image-overlays))
>(should (null (overlays-in (point-min) (point-max
>(org-show-subtree)
>(should-not org-inline-image-overlays)
>(should-not (overlays-in (point-min) (point-max)))
> #+end_src
>
>
> And failed after command:
>
> #+begin_src shell
> make BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty 
> #+end_src
>
>
> Here is the output:
>
> #+begin_example
> ~/Code/Emacs/org-mode:main*:1 λ make 
> BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty  
> install -m 755 -d 
> /var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T//tmp-orgtest
> TMPDIR=/var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T//tmp-orgtest emacs  
> -Q -batch --eval '(setq vc-handled-backends nil org-startup-folded nil 
> org-element-cache-persistent nil)'  --eval '(add-to-list '"'"'load-path 
> (concat default-directory "lisp"))' --eval '(add-to-list '"'"'load-path 
> (concat default-directory "testing"))'  -l org-batch-test-init --eval '(setq 
> org-batch-test t org-babel-load-languages (quote ( (awk

Re: [BUG] Org mode does not recognize the last character "_" in URL link

2022-10-19 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> When URL has a character "_" at the end, Org mode can't fontify the URL
>> link correctly.
>>
>> For example:
>>
>> https://www.twitter.com/example_
>
> Plain links are tricky. There is no definitive regexp to catch all
> possible links. We use heuristics.
>
> If you see anything we can improve in org-link-make-regexps, patches are
> welcome.

I have checked out the function `org-link-make-regexps' source code, the
regexp is hard to understand for me. I will study it when I got time to
figure whether I can improve it. Thanks for your hint.

-- 

[ 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


[SOLVED] Re: [CLOSED] text-property displayed image has a center-line when the text face has underline attribute

2022-10-19 Thread Christopher M. Miles

Eli Zaretskii  writes:

>> From: Ihor Radchenko 
>> Date: Sun, 2 Oct 2022 18:57:56 +0800
>> Cc: Eli Zaretskii , emacs-de...@gnu.org, emacs-orgmode@gnu.org
>> 
>> 1. find an image file in your system
>> 2. emacs -Q
>> 3. M-: (erase-buffer)
>> 4. Insert "askdjaklsdj lasasd"
>> 5. M-: (require 'org)
>> 6. M-x font-lock-mode
>> 7. M-: (put-text-property (point-min) (point-max) 'face 'org-link)
>> 8.  M-: (put-text-property (point-min) (point-max) 'display (create-image
>> "/path/to/image" nil nil :ascent 'center :max-height 512))
>
> Thanks.
>
> This is because of the ":ascent 'center" part, isn't it?
>
> What would you want Emacs to do instead in this case?

I checked out the docstring of `create-image' have not found related
info about `:ascent'. Today (which is after some days) I review this
problem and searched the `:ascent' in emacs info manual, found this
property explanation. I set it to `:ascent 100` solved the problem. Now
the baseline is at the bottom of image.

Thanks a lot for pointing it out which fixed a big issue of my extension code.

-- 

[ 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


[BUG] Org mode does not recognize the last character "_" in URL link

2022-10-17 Thread Christopher M. Miles

When URL has a character "_" at the end, Org mode can't fontify the URL
link correctly.

For example:

https://www.twitter.com/example_

-- 

[ 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


Re: [PATCH] (v2) Fix void variable error `cider-buffer-ns` when specifying :backend header argument

2022-10-12 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> After updated to latest commit, I found error,
>>
>> Reproduce:
>>
>> When I specified the `:backend` header argument:
>>
>> #+begin_src clojure :backend babashka
>> (+ 2 4)
>> #+end_src
>>
>> I got error:
>>
>> #+begin_example
>> void variable: cider-buffer-ns
>> #+end_example
>
> Thanks for reporting!
>
>> Here is the patch fix upper issue.
>>
>>(let* ((vars (org-babel--get-vars params))
>> + (backend-override (cdr (assq :backend params)))
>>   (ns (or (cdr (assq :ns params))
>> - (if (eq org-babel-clojure-backend 'cider)
>> + (if (and (not backend-override)
>> +  (eq org-babel-clojure-backend 'cider))
>>   (or cider-buffer-ns
>>   (let ((repl-buf (cider-current-connection)))
>> (and repl-buf (buffer-local-value
>
> What if backend-override is 'cider?
> I suggest to let-bind
> (org-babel-clojure-backend
>   (cond
>(backend-override (intern backend-override))
>(org-babel-clojure-backend org-babel-clojure-backend)
>(t (user-error "You need to customize `org-babel-clojure-backend'
> or set the `:backend' header argument"
>
> Just like in `org-babel-execute:clojure'.

You're right, updated now.

From 1ecdcc596c8447fcf96ff400f544c0adc680c8fc Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Wed, 12 Oct 2022 17:27:58 +0800
Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with
 `org-babel-clojure-backend'

* lisp/ob-clojure.el (org-babel-expand-body:clojure): When The source
block specified header argument :backend, the global option
`org-babel-clojure-backend' value is default 'cider, the
`cider-buffer-ns` is not void error.
---
 lisp/ob-clojure.el | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index d6f860e98..0649469b3 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -104,6 +104,13 @@
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let* ((vars (org-babel--get-vars params))
+ (backend-override (cdr (assq :backend params)))
+ (org-babel-clojure-backend
+  (cond
+   (backend-override (intern backend-override))
+   (org-babel-clojure-backend org-babel-clojure-backend)
+   (t (user-error "You need to customize `org-babel-clojure-backend'
+or set the `:backend' header argument"
 	 (ns (or (cdr (assq :ns params))
 		 (if (eq org-babel-clojure-backend 'cider)
 		 (or cider-buffer-ns
-- 
2.37.2


-- 

[ 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


[PATCH] Fix void variable error `cider-buffer-ns` when specifying :backend header argument

2022-10-11 Thread Christopher M. Miles

After updated to latest commit, I found error,

Reproduce:

When I specified the `:backend` header argument:

#+begin_src clojure :backend babashka
(+ 2 4)
#+end_src

I got error:

#+begin_example
void variable: cider-buffer-ns
#+end_example

Here is the patch fix upper issue.

From 245fc50b2eae115144c83ad97c1f9490f525b062 Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Wed, 12 Oct 2022 08:32:50 +0800
Subject: [PATCH] lisp/ob-clojure.el: Fix :backend override not work with
 `org-babel-clojure-backend'

* lisp/ob-clojure.el (org-babel-expand-body:clojure): When The source
block specified header argument :backend, the global option
`org-babel-clojure-backend' value is default 'cider, the
`cider-buffer-ns` is not void error.
---
 lisp/ob-clojure.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index d6f860e98..a6a463b83 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -104,8 +104,10 @@
 (defun org-babel-expand-body:clojure (body params)
   "Expand BODY according to PARAMS, return the expanded body."
   (let* ((vars (org-babel--get-vars params))
+ (backend-override (cdr (assq :backend params)))
 	 (ns (or (cdr (assq :ns params))
-		 (if (eq org-babel-clojure-backend 'cider)
+		 (if (and (not backend-override)
+  (eq org-babel-clojure-backend 'cider))
 		 (or cider-buffer-ns
 			 (let ((repl-buf (cider-current-connection)))
 			   (and repl-buf (buffer-local-value
-- 
2.37.2


-- 

[ 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


Re: [PATCH 2-v4] New: auto display inline images under subtree when `org-cycle'.

2022-10-10 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>>> I think that the best we can do in this situation is mocking
>>> `create-image' in batch mode to return non-nil using `cl-letf'.
>>
>> I checked the `create-image' in image.el source code, don't know how to
>> mocking this. I have no experience and idea about this. I also searched
>> org testing. Have not found similar situations.
>>
>> If you have idea how to write this test, I suggest pass this word to
>> you. What do you think?
>
> I imagine something like
>
> ;; Mock `create-image' to work noninteractively.
> (cl-letf (((symbol-function 'create-image)
>  (lambda ( _)
>`(image :type "dummy" :data "dummy"
>   )

After wrapped your cl-letf redefining function binding. Still failed on test.

Here is the new test code:

#+begin_src emacs-lisp
(ert-deftest test-org-fold/org-fold-display-inline-images ()
  "Test inline images displaying when cycling."
  ;; Mock `create-image' to work noninteractively.
  (cl-letf (((symbol-function 'create-image)
 (lambda ( _) `(image :type "dummy" :data "dummy"
(let* ((org-cycle-inline-images-display t)
   (images-dir (expand-file-name "examples/images/" org-test-dir))
   (org-logo-image (expand-file-name "Org mode logo mono-color.png" 
images-dir)))
  ;; `org-cycle' -(state)-> `'children' display child inline images.
  (org-test-with-temp-text
   (format "* Heading 1
[[file:%s]]
" org-logo-image)
   (org-overview)
   ;; (org-cycle)
   ;; (org-cycle-internal-local)
   ;; (org-cycle-display-inline-images 'children)
   (org-fold-show-children)
   (run-hook-with-args 'org-cycle-hook 'children)
   (org-next-link)
   (should org-inline-image-overlays)
   (should (overlays-at (point)))
   (org-toggle-inline-images)
   (should-not (overlays-at (point
  
  ;; `org-cycle' -(state)-> `'subtree' display subtrees inline images.
  (org-test-with-temp-text
   (format "* Heading 1
[[file:%s]]
** Subheading 1
[[file:%s]]
** Subheading 2
[[file:%s]]" org-logo-image org-logo-image org-logo-image)
   (org-overview)
   ;; (org-cycle)
   ;; (org-cycle)
   ;; (org-cycle-internal-global)
   (org-fold-show-subtree)
   (run-hook-with-args 'org-cycle-hook 'subtree)
   (org-next-link)
   (org-next-link)
   ;; (should org-inline-image-overlays)
   (should (overlays-at (point)))
   (org-toggle-inline-images)
   (should-not (overlays-at (point
  
  ;; `org-cycle' -(state)-> `'folded' remove inline image overlays.
  (org-test-with-temp-text
   (format "* Heading 1
[[file:%s]]
** Subheading 1
[[file:%s]]
** Subheading 2
[[file:%s]]" org-logo-image org-logo-image org-logo-image)
   (org-overview)
   (org-show-subtree)
   (org-fold-subtree t)
   (run-hook-with-args 'org-cycle-hook 'folded)
   (should (null org-inline-image-overlays))
   (should (null (overlays-in (point-min) (point-max
   (org-show-subtree)
   (should-not org-inline-image-overlays)
   (should-not (overlays-in (point-min) (point-max)))
#+end_src

And failed after command:

#+begin_src shell
make BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty 
#+end_src

Here is the output:

#+begin_example
~/Code/Emacs/org-mode:main*:1 λ make 
BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty  
install -m 755 -d /var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T//tmp-orgtest
TMPDIR=/var/folders/ym/f3v5_yk1279g5ls70x3hzblhgn/T//tmp-orgtest emacs  -Q 
-batch --eval '(setq vc-handled-backends nil org-startup-folded nil 
org-element-cache-persistent nil)'  --eval '(add-to-list '"'"'load-path (concat 
default-directory "lisp"))' --eval '(add-to-list '"'"'load-path (concat 
default-directory "testing"))'  -l org-batch-test-init --eval '(setq 
org-batch-test t org-babel-load-languages (quote ( (awk . t)  (C . t)  (fortran 
. t)  (maxima . t)  (lilypond . t)  (octave . t)  (perl . t)  (python . t)  
(emacs-lisp . t)  (shell . t)  (org . t))) org-test-select-re 
"test-org-fold/org-fold-display-inline-images" )' -l org-loaddefs.el -l cl -l 
testing/org-test.el -l ert -l org -l ox -l ol  --eval 
'(org-test-run-batch-tests org-test-select-re)'
Package cl is deprecated
Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org.el' newer than 
byte-compiled file; using older file
Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-compat.el' newer 
than byte-compiled file; using older file
Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-macs.el' newer 
than byte-compiled file; using older file
Source file `/Users/stardiviner/C

Re: [PATCH v2] Re: org-contacts: Dead link at https://orgmode.org/worg/org-contrib/index.html

2022-10-09 Thread Christopher M. Miles

Ihor Radchenko  writes:

> "Christopher M. Miles"  writes:
>
>> From 1521f4e27360d536197ee0ac524a641aad02822f Mon Sep 17 00:00:00 2001
>> From: stardiviner 
>> Date: Sat, 8 Oct 2022 20:40:34 +0800
>> Subject: [PATCH] Fix dead link of org-contacts
>
> Thanks!
>
>>  org-contrib/org-contacts.org | 30 ++
>
> Could you please use the standard WORG file template described in
> https://orgmode.org/worg/worg-editing.html?

Ok, I updated org-contacts.org file now. Check out the new patch.

From 0920dfa762a82f3c934b2eb11fcf7202c1cb194e Mon Sep 17 00:00:00 2001
From: stardiviner 
Date: Sat, 8 Oct 2022 20:40:34 +0800
Subject: [PATCH] Fix dead link of org-contacts

---
 org-contrib/index.org|  9 +---
 org-contrib/org-contacts.org | 40 
 2 files changed, 46 insertions(+), 3 deletions(-)
 create mode 100644 org-contrib/org-contacts.org

diff --git a/org-contrib/index.org b/org-contrib/index.org
index 628d9493..b9f42af4 100644
--- a/org-contrib/index.org
+++ b/org-contrib/index.org
@@ -66,9 +66,6 @@ the package -- it will hopefully have some documentation.
   Written by /Eric Schulte/.
   [[contribfile:lisp/org-collector.el][Link to raw file]].
 
-- [[contribfile:lisp/org-contacts.el][/org-contacts.el/ -- manage contacts (org-plus-contrib)]] ::
-  Written by /Julien Danjou/, now in Org contrib.
-
 - [[file:org-depend.org][/org-depend.el/ -- TODO dependencies for Org-mode]] ::
   Make TODO state changes in one entry trigger changes in another, or
   be blocked by the state of another entry.  Also, easily create
@@ -426,6 +423,12 @@ See [[file:../exporters/index.org][Exporters]].
   images in email.  Written by /Eric Schulte/, maintained by /Chen Bin/.
   [[https://github.com/org-mime/org-mime][Repo]].
 
+- [[file:org-contacts.org][/org-contacts.el/ -- manage contacts]] ::
+  Managing contacts information, recording, searching etc in Org
+  mode. As contacts database backend for mu4e etc.  Written by /Julien
+  Danjou/, now maintained by /stardiviner/. Link to [[https://repo.or.cz/org-contacts.git][project repo
+  page]].
+
 * Obsolete
 
 - [[file:org-annotation-helper.org][/org-annotation-helper.el/ -- managing browser bookmarks]] ::
diff --git a/org-contrib/org-contacts.org b/org-contrib/org-contacts.org
new file mode 100644
index ..6e3d20b0
--- /dev/null
+++ b/org-contrib/org-contacts.org
@@ -0,0 +1,40 @@
+#+TITLE: org-contacts.el -- managing contacts information in Org mode
+#+OPTIONS:   ^:{} author:nil
+#+STARTUP: odd
+
+# This file is released by its authors and contributors under the GNU
+# Free Documentation license v1.3 or later, code examples are released
+# under the GNU General Public License v3 or later.
+
+* Intro
+
+- Managing contacts information in Org mode.
+- Recording contact info in Org mode.
+- Searching with command ~org-contacts~.
+- Used as contacts database backend for email address completing in mu4e etc.
+- Export contacts to a vCard file.
+- Put birthdays in your Org Agenda.
+
+* Installation
+
+Package has been submitted to NonGNU or MELPA. You can install it through those package sources.
+
+* Usage
+
+More details you can check out [[https://repo.or.cz/org-contacts.git][org-contacts.el project page's README.org]].
+
+** Search contact in org-contacts databse
+
+Use command =[M-x org-contacts]= to search.
+
+** Complete contact property with some functions support
+
+*** NAME
+
+*** NICK
+
+*** EMAIL
+
+*** BIRTHDAY
+
+
-- 
2.37.2


-- 

[ 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


Re: [PATCH] LSP support in org-src buffers

2022-10-08 Thread Christopher M. Miles

+1

Good patch, will it consider to also support package "lsp-mode"? Or at
least make it easy to extending for other lsp-related packages?

-- 

[ 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


  1   2   3   >