Re: [BUG] [C-u C-u C-c C-o] open link with external program invalid to open file

2021-03-11 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

I see, I added your patch to my Emacs config. Really thanks for your work. And 
wait for maintainer response.

Maxim Nikulin  writes:

Christopher, if your are still interested in a patch against this issue then 
you could find one in 
https://orgmode.org/list/eff43744-12e1-a359-39f2-6d8169350...@gmail.com/ It 
managed to pass unnoticed by Bastien's dog somehow.

I have realized that I used "'" for function references, that should be 
replaced by "#'". I have not posted updated version waiting for more comments.

On the other hand there was a suggestion by Eli Zaretskii to just surround 
start-process-shell-command with (let ((process-connection-type nil)) …).
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: Is it possible to optimize Org Mode org-activate-links ?

2021-02-12 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

Thanks for your hints.

Should I use the following options? I saw the warning. Does this freeze happens 
often? I decide to try it.

(defvar org-element-use-cache nil
  "Non-nil when Org parser should cache its results.

WARNING: for the time being, using cache sometimes triggers
freezes.  Therefore, it is disabled by default.  Activate it if
you want to help debugging the issue.")

(defvar org-element-cache-sync-idle-time 0.6
  "Length, in seconds, of idle time before syncing cache.")

(defvar org-element-cache-sync-duration 0.04
  "Maximum duration, as a time value, for a cache synchronization.
If the synchronization is not over after this delay, the process
pauses and resumes after `org-element-cache-sync-break'
seconds.")

(defvar org-element-cache-sync-break 0.3
  "Duration, as a time value, of the pause between synchronizations.
See `org-element-cache-sync-duration' for more information.")


Ihor Radchenko  writes:

Christopher Miles  writes:
I checked org-element-context source code, it's not so long and complex. Why it 
caused so many items in Memory profiler result? Is it possible to optimize it?

You can try to use org-element-cache. That might help.

Best, Ihor
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Is it possible to optimize Org Mode org-activate-links ?

2021-02-12 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

I did an profiler (with my extension "org-link-beautify").

Here is the result of (Memory and CPU).

I checked org-element-context source code, it's not so long and complex. Why it 
caused so many items in Memory profiler result? Is it possible to optimize it?

Here is the Emacs profiler (CPU) result:


8   2%  - org-activate-links
8   2%   - catch
8   2%- while
6   2% - let*
6   2%  - if
6   2%   - progn
6   2%- let*
5   1% - let
5   1%  - if
5   1%   - progn
5   1%- funcall
5   1% - org-link-beautify-display
2   0%  - org-link-beautify--return-icon
2   0% org-link-beautify--warning
2   0%file-name-extension
1   0%  - org-link-beautify--preview-pdf
1   0%   - org-link-beautify--display-thumbnail
1   0%- create-image
1   0% - apply
1   0%  - #
1   0%   - image-type
1   0%- image-type-from-file-header
1   0%   generate-new-buffer
1   0% - let*
1   0%  - cond
1   0%   - or
1   0%  facep


Here is the Emacs profiler (Memory) result:


1,939,896  11%  - org-activate-links
1,939,896  11%   - catch
1,939,896  11%- while
1,761,816  10% - let*
1,761,816  10%  - if
1,697,400   9%   - progn
1,658,488   9%- let*
1,511,048   8% - let
1,511,048   8%  - if
1,511,048   8%   - progn
1,511,048   8%- funcall
1,511,048   8% - org-link-beautify-display
  947,000   5%  - org-link-beautify--get-element
  947,000   5%   - org-element-context
  947,000   5%- catch
  947,000   5% - save-excursion
  947,000   5%  - save-restriction
  947,000   5%   - let*
  792,384   4%- let
  792,384   4% - catch
  792,384   4%  - while
  792,384   4%   - let
  792,384   4%- org-element--object-lex
  792,384   4% - if
  792,384   4%  - let*
  792,384   4%   - save-excursion
  792,384   4%- while
  661,368   3% - let
  655,272   3%  - setq
  655,272   3%   - cond
  655,272   3%- let*
  655,272   3% - cond
  610,224   3%  - let*
  610,224   3%   - cond
  610,224   3%- if
  610,224   3% - progn
  610,224   3%  - 
org-element-link-parser
  610,224   3%   - catch
  610,224   3%- let
  450,480   2% - cond
  225,240   1%  - setq
  225,240   1%   - 
org-link-expand-abbrev
  139,248   0%- 
org-link-unescape
  131,064   0% - 
replace-regexp-in-string
8,184   0%apply
   85,992   0%- if
   77,808   0%   not
8,184   0% - let*
8,184   0%and
  163,800   0%  - cond
   61,440   0% or
8,184   0% setq
  159,744   0% - if
   98,304   0%  - progn
   49,152   0% if
   49,152   0%   - setq
   49,152   0%  
replace-regexp-in-string
   45,048   0%   

[SOLVED] Re: [ISSUE] org-agenda with clocktable infinite on logbook which has text-propertize links

2021-02-05 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

Problem solved by adding an condition to detect current mode whether it is 
org-agenda-mode.
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: patch: ob-clojure improvements

2021-02-03 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

You're right, seems now need to wait for Ag Ibragimov.

Tim Cross  writes:

OK. As the patch is over 6 months old, it would be good if the original author 
can confirm it is still the latest version and if not, re-send the most recent 
version.

Christopher Miles  writes:

<#!secure method=pgpmime mode=sign>

I checked this thread, seems the original first email of thread contains the 
patch. And it's not merged into Org git yet.

Tim Cross  writes:

OK, will push it up the todo list. Where can I get the latest version of the 
patch or has it been added into the org git repo?

Christopher Miles  writes:

<#!!secure method=pgpmime mode=sign>

Hi, Tim, popup this thread to request review. 😄

Tim Cross  writes:

I am also interested in ob-clojure and ob-clojurescript improvements. However, 
right now, I'm a tad busy and haven't had time to review what has been done. 
Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

agzam.ibragi...@gmail.com writes:

There seems to be a bit of lack of interest for these things. But I'm sure some 
people (myself included) would love to see these kinds of improvements.

Yes, I rarely saw Clojurians in this mailing list.

As I said before, I have never participated in contributing to Org source, some 
guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

Should I keep building it and posting patches? Should I try to go 
incrementally, one small change at a time, or should I just get everything 
working first? If it turns out to be a bigger work, should I ask for permission 
to work in a branch and get access to pushing things to it? Maybe things just 
move slowly, because obviously you can't force maintainers to drop everything 
and concentrate effort to get your things in. Maybe I just have to be a little 
bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support for 
ob-clojure.el - Adds a header parameter to override org-babel-clojure-backend - 
Adds :args param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
{:mvn/version \"0.13.2\"}}}'" (use 'inflections.core) (plural "word") #+endsrc

#+beginsrc clojure :backend babashka :results output (range 10) #+endsrc

Please let me know what you think. Any advice is appreciated, since I have 
never contributed before. Thank you.

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

Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: 
stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
s
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: patch: ob-clojure improvements

2021-02-02 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

I checked this thread, seems the original first email of thread contains the 
patch. And it's not merged into Org git yet.

Tim Cross  writes:

OK, will push it up the todo list. Where can I get the latest version of the 
patch or has it been added into the org git repo?

Christopher Miles  writes:

<#!secure method=pgpmime mode=sign>

Hi, Tim, popup this thread to request review. 😄

Tim Cross  writes:

I am also interested in ob-clojure and ob-clojurescript improvements. However, 
right now, I'm a tad busy and haven't had time to review what has been done. 
Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

agzam.ibragi...@gmail.com writes:

There seems to be a bit of lack of interest for these things. But I'm sure some 
people (myself included) would love to see these kinds of improvements.

Yes, I rarely saw Clojurians in this mailing list.

As I said before, I have never participated in contributing to Org source, some 
guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

Should I keep building it and posting patches? Should I try to go 
incrementally, one small change at a time, or should I just get everything 
working first? If it turns out to be a bigger work, should I ask for permission 
to work in a branch and get access to pushing things to it? Maybe things just 
move slowly, because obviously you can't force maintainers to drop everything 
and concentrate effort to get your things in. Maybe I just have to be a little 
bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support for 
ob-clojure.el - Adds a header parameter to override org-babel-clojure-backend - 
Adds :args param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections 
{:mvn/version \"0.13.2\"}}}'" (use 'inflections.core) (plural "word") #+endsrc

#+beginsrc clojure :backend babashka :results output (range 10) #+endsrc

Please let me know what you think. Any advice is appreciated, since I have 
never contributed before. Thank you.

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

Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner, Matrix: 
stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: patch: ob-clojure improvements

2021-02-02 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

Hi, Tim, popup this thread to request review. 😄

Tim Cross  writes:

I am also interested in ob-clojure and ob-clojurescript improvements. However, 
right now, I'm a tad busy and haven't had time to review what has been done. 
Hopefully, can make some time in the next month or so.

Tim

stardiviner  writes:

agzam.ibragi...@gmail.com writes:

There seems to be a bit of lack of interest for these things. But I'm sure some 
people (myself included) would love to see these kinds of improvements.

Yes, I rarely saw Clojurians in this mailing list.

As I said before, I have never participated in contributing to Org source, some 
guidance would be appreciated.

Org Mode has contribution guide here 
http://orgmode.org/worg/org-contribute.html#patches

Should I keep building it and posting patches? Should I try to go 
incrementally, one small change at a time, or should I just get everything 
working first? If it turns out to be a bigger work, should I ask for permission 
to work in a branch and get access to pushing things to it? Maybe things just 
move slowly, because obviously you can't force maintainers to drop everything 
and concentrate effort to get your things in. Maybe I just have to be a little 
bit more patient?

I think a complete work contains many patches should be better, Also write 
testing if necessary.

I remember ob-clojure.el code are mostly reviewed by Bastien Guerry. I included 
him in Cc: in this email.

On Sat, Jun 20, 2020 at 1:23 AM stardiviner  wrote:

Glad to see your patch, really useful in some cases. Thanks.

Ag Ibragimov  writes:

Hi everyone, here's my attempt to add clojure CLI and babashka support
for ob-clojure.el
- Adds a header parameter to override org-babel-clojure-backend - Adds :args 
param (right now only used for clojure-cli)

I have tested it with these minimal cases:

#+beginsrc clojure :backend clj-cli :args "-Sdeps '{:deps {inflections
{:mvn/version \"0.13.2\"}}}'"
(use 'inflections.core) (plural "word") #+endsrc

#+beginsrc clojure :backend babashka :results output (range 10) #+endsrc

Please let me know what you think. Any advice is appreciated, since I
have never contributed before. Thank you.

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

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

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

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


Re: word counts and org-mode drawers

2021-02-01 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

Sharon Kimble  writes:

–—BEGIN PGP SIGNED MESSAGE–— Hash: SHA512

Hi folks.

How can I exempt an org-mode drawer, and its contents, from word counts please. 
I am using 'wc-mode' but I can't see how to do it.

Thanks Sharon.

I remember there is an extension called org-wc, did this thing. Suggest you to 
use that.

- – Debian 10.7, fluxbox 1.3.7, emacs 27.1.50, org 9.4.4 –—BEGIN PGP SIGNATURE–—

iQJPBAEBCgA5FiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAmAYG6cbHGJvdWRpY2Nh 
c0Bza2ltYmxlLnBsdXMuY29tAAoJEDaBgBkK+INbCiMP+wU4WdnwbY9FEji4Ns56 
5nHDTCFolp1zvG3uuTWz2UIQl3dfyDiJeOHejFP/G77xNBXJrYFWXNb52TpvL436 
lvGGDsKewPaY+fRryxcXAq8EcOdI0AE3E62GJpX7iMAGXOGVGTjQY0Cpwi3owyHs 
R05UOiDcJJfNg+2oEK0sVL7HFk1Sg1o2vzbVI5Lxfj5/KR1ZuTJXkSvTiT1FgZBq 
j6+aXqlsqQvImINYxRHZ/oynU7PhuUFG5v8Gk6XHjERi2ia+BZWUev0AvrbYwCx0 
r0Zb5JPBg2gqBQ+Vk4PVd1cdz+n4jNGn+gZpJnxMF7rP4yzLjBKAwPzwnRiPgaEl 
OMfnn0x1NzdejLm3B363dOusTG/cwCIABFap9y3xgoRLpord+xBWywtJqgZhEqAs 
yAfE9erl0ON9UZD3gI2xspfsuRwIAkcjMQDQR8Ej2SAG1IClGVOEkECGV+tu7kSN 
lHWd/PCXXWQTaE9LR1QePUj6naRNqZCY1JfM2upoBXhcSB31r0v9K4zfnYM14qu3 
jS5NQasGKR74oSyboIlUyX+5M3r6Iowg57dGVM0JR3nB5O7XenFQv67iqWojYM4L 
jxCxFgflgh0ebRqxCEzMV5NiJiGfGAuGliwerB8l/lXkIjLuQ8ZxyjV0MbQe7BUk 
ngEgy0ZeKO8dG1z0GAgZfYkx =Ri0D –—END PGP SIGNATURE–—
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


[QUESTION] How to use `make-thread` to run org-babel-execute-src-block?

2021-01-31 Thread Christopher Miles
<#secure method=pgpmime mode=sign>

I have following code snippet config:

(defun org-property-eval-on-cycle-expand (&optional 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 "EVAL" nil)))
(with-temp-buffer
  (insert inline-src-block)
  (goto-char (point-min))
  (require 'ob-async nil t)
  (setq-local org-babel-default-inline-header-args
  '((:results . "silent") (:async . t)))
  (let* ((context (org-element-context))
 (src-block-info (org-babel-get-src-block-info nil context))
 (type (org-element-type context)))
(when (eq type 'inline-src-block)
  ;; TODO use `make-thread'
  ;; ob-async: advice `org-babel-execute-src-block:async' on 
‘org-babel-execute-src-block’
  (org-babel-execute-src-block nil src-block-info)))

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


I use upper config in bellowing case to auto play video when I expand headline.

* eval inline src code block
  :PROPERTIES:
  :EVAL: src_sh{mpv "video.mp4"}
  :END:



As upper code snippet marked TODO comment. Because I'm using ob-async. So the 
org-babel-execute-src-block is async by default with ob-async's advice. I want 
to get rip of it. Using make-thread, I tried to use (make-thread FUNCTION) (the 
FUNCTION is a wrapper of org-babel-execute-src-block) but it will block current 
Emacs instance. How to make it async without blocking current Emacs?

Hope someone can help me. Thank you in advance.
-- 
[ stardiviner ]
   I try to make every word tell the meaning that I want to express.

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


Re: [PATCH] Re: [BUG] [C-u C-u C-c C-o] open link with external program invalid to open file

2021-01-21 Thread Christopher Miles

Maxim Nikulin  writes:

> On 21/01/2021 07:58, Christopher Miles wrote:
>> 
>> I "=git am=" your first patch, but failed to apply your second patch. Seems 
>> not
>> continuous. So I modify code manually. I found I can't find the local 
>> variable
>> ~shell-command~, and ~shell-command-switch~. Can your provide complete 
>> patch? So I
>> can test it.
>
> Second patch is an alternative to the first one. I could do 'git apply 
> org-open-file-make-process-min.patch' to the current master with no 
> conflict. However you are right, it should be ~shell-file-name~, not 
> ~shell-command~. There is a typo in ~shell-command-switch~. Both 
> ~shell-file-name~ and ~shell-command-switch~ are defined in emacs 
> sources, they are not local variables.

Indeed, I learned new stuff. 😄

>
> I do not think that the first patch could be accepted in any form. 
> Launching a handler without shell is a serious change. However trying to 
> rewrite that part, I realized that original code has a problem.
>
> I intentionally do not add formal patch description since I suppose that 
> error reporting should be improved.

You're right, the error handling can be improved.

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

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


signature.asc
Description: PGP signature


[PATCH] Re: [BUG] [C-u C-u C-c C-o] open link with external program invalid to open file

2021-01-20 Thread Christopher Miles

Maxim Nikulin  writes:

> I have realized that :filter argument is not appropriate to arbitrary 
> handler that could spam with various assert messages. Maybe :sentinel is 
> better to report configuration problem to user when handler is called 
> with inappropriate arguments.

Yes, use ~:sentinel~ is better for report problem when detect process failed or
configuration error. ~:filter~ usually used in handling process output.

I "=git am=" your first patch, but failed to apply your second patch. Seems not
continuous. So I modify code manually. I found I can't find the local variable
~shell-command~, and ~shell-command-switch~. Can your provide complete patch? 
So I
can test it.

I update subject to prefix with [PATCH] so that reader knows this thread is on
patch discussion.

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

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


signature.asc
Description: PGP signature


Re: [BUG] [C-u C-u C-c C-o] open link with external program invalid to open file

2021-01-19 Thread Christopher Miles

Maxim Nikulin  writes:

> On 19/01/2021 08:53, Christopher Miles wrote:
>> 
>> For this problem, do you have any workable solution patch?
>
> Maybe for a while it is better to avoid xdg-open or other handlers that 
> launch actual viewers in background. E.g. to replace xdg-open with 
> actual handlers in mailcap.
>
> I attach a draft patch that just demonstrates my intention to use 
> make-process. It intentionally does not use shell to run the command and 
> such change could be breaking for some part of users. I have not tested 
> if regexp substitutions for org-file-apps entries are not broken.
>
> In kubuntu-18.04 I do not have any xdg-open entries in the system 
> mailcap file. Even if I add such line to the user's file, I could not 
> reproduce the problem with any of the real handler configured for the 
> image/png type and launched by xdg-open: geeqie, gwenview, feh. I have 
> no idea concerning the reason: older xdg-open version, other code 
> working in xdg-open for kde desktop, or limited resources allocated to 
> qemu virtual machine with ubuntu-20.04 where I can reproduce the problem.

Thanks for your working. I will modify my mailcap config temporary until Org
Mode fix this issue. You're right, this change might break some behavior of some
users. I don't understand Emacs sub-process mechanism. Can't help on this
problem. But I'm interested in this. I will take some time to study in. Anyway,
thanks for your work.

Regards,

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

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


signature.asc
Description: PGP signature


Re: [BUG] [C-u C-u C-c C-o] open link with external program invalid to open file

2021-01-18 Thread Christopher Miles

Maxim, thanks for your detailed explanation.

I confirmed the problem:

#+begin_src emacs-lisp
;;; does not work
(start-process-shell-command "xdg-open" nil "xdg-open 
/usr/share/icons/gnome/256x256/actions/stock_print.png")

;;; works fine
(start-process-shell-command "feh" nil "feh 
/usr/share/icons/gnome/256x256/actions/stock_print.png")
#+end_src

For this problem, do you have any workable solution patch?

Here is my =/etc/mailcap=, don't have =~/.mailcap=.

#+begin_src conf
### 
### Begin Red Hat Mailcap
###

audio/*; /usr/bin/xdg-open %s

image/*; /usr/bin/xdg-open %s

application/msword; /usr/bin/xdg-open %s
application/pdf; /usr/bin/xdg-open %s
application/postscript ; /usr/bin/xdg-open %s

text/html; /usr/bin/xdg-open %s ; copiousoutput
#+end_src

Maxim Nikulin  writes:

> On 05/09/2020 14:52, Bastien wrote:
>> 
>> stardiviner  writes:
>> 
>>> When I press =[C-u C-u C-c C-o]= to open an image file link with system 
>>> external
>>> program. It can't open the image file.
>> 
>> I cannot reproduce the problem here.
>> 
>> If you still have this issue, can you provide a minimal reproducible
>> example?
>
> Christopher Miles recently posted a link to askubuntu that shed some 
> light on the problem.
>
> I have compared the following commands:
>
> (start-process-shell-command "xdg-open" nil "xdg-open 
> /usr/share/icons/gnome/256x256/actions/stock_print.png")
> (start-process-shell-command "eog" nil "eog 
> /usr/share/icons/gnome/256x256/actions/stock_print.png")
>
> The latter works in my (test) case (Ubuntu-20.04, ubuntu session - 
> gnome), the former does not. If I do not mistake, 
> start-process-shell-command is what org mode uses to open file.
>
> Meaningful lines from strace of the emacs process
>
> 24108 21:39:51 execve("/bin/bash", ["/bin/bash", "-c", "xdg-open 
> /usr/share/icons/gnome/"...], 0x7ffcb1c1fdb0 /* 55 vars */ 
> 24116 21:39:51 execve("/usr/bin/eog", ["eog", 
> "/usr/share/icons/gnome/256x256/a"...], 0x55d009672ec8 /* 57 vars */ 
> 
> 24108 21:39:51 +++ exited with 0 +++
> 24116 21:39:51 +++ killed by SIGHUP +++
>
> I think, the problem is that start-process-shell-command creates a "pty" 
> process. As soon as main command exits, all children, that belong to the 
> same terminal session created by emacs for the process, got killed.
>
> Calling eog directly works because of it does not attempt to go to 
> background or demonize.
>
> The solution could be (make-process :connection-type 'pipe ...). 
> Personally I would prefer to avoid shell as well when it is not really 
> necessary.
>
> I am surprised that in the discussion of problem related to desktop 
> integration and perhaps even order in which applications able to handle 
> particular file format were installed, nobody mentioned such details, 
> neither for "positive" nor for "negative" results. Probably output of 
> the following commands (for the proper mime type) could be relevant. The 
> complication is that there are several mime handler "databases".
>
> grep image/png /etc/mailcap ~/.mailcap
> xdg-mime query default image/png
>
> (mailcap-parse-mailcaps)
> (mailcap-mime-info "image/png")
>
> For some handlers there might be even a race, sometimes it might work 
> but might fail as well, depending if child could send a message to its 
> server quickly enough. In such case providing of ECM might be a challenge.


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

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


signature.asc
Description: PGP signature


Re: [feature request] A new cookie type [!] showing the last note taken

2021-01-17 Thread Christopher Miles

I think this is possible through read last note text in logbook, then display it
in headline through text-property overlay.

That's what I did in this package 
[[https://github.com/stardiviner/org-link-beautify]]

Should not be that hard to implement it.

Ihor Radchenko  writes:

> Over the years of using Org I often have a need to add a short note
> about how to proceed with some task:
>
> * REVIEW check again, subscribe | sindresorhus/awesome: 😎 Awesome lists 
> about all kinds of interesting topics :BOOKMARK:
> :PROPERTIES:
> :CREATED: [2020-03-15 Sun 18:59]
> :Source: https://github.com/sindresorhus/awesome
> :END:
> :LOGBOOK:
> CLOCK: [2020-03-17 Tue 16:18]--[2020-03-17 Tue 17:46] =>  1:28
> CLOCK: [2020-03-17 Tue 16:03]--[2020-03-17 Tue 16:18] =>  0:15
> - Refiled on [2020-03-16 Mon 23:59]
> :END:
>
> In the above example, the short note is "check again, subscribe".
> The note is not fixed, but changes as I progress with completing the
> task.
>
> This is even more useful for delegated or HOLD tasks where I often need
> to add a short note why the task is delegated or put on hold:
>
> ** HOLD Finish the text prop org-mode | make babel support org file links in 
> header args (:file or :dir) 
> [[id:468e0645-68aa-4e14-86de-e5ce153538e3][[2017-09-22 Fri] 
> CuNbARBshearstrength]] :HOLD:
> :PROPERTIES:
> :CREATED: [2020-07-20 Mon 16:53]
> :SHOWFROMDATE: 2020-08-15
> :END:
> :LOGBOOK:
> - State "HOLD"   from "NEXT"  [2020-08-10 Mon 15:16] \\
>   Finish the text prop org-mode
> - Refiled on [2020-07-20 Mon 17:15]
> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
> :END:
>
> Seeing this note directly in the headline without a need to dig into the
> task body / LOGBOOK drawer is really handy.
>
> In this last example, I had to duplicate the note taken using built-in
> note mechanism into headline, which was inconvenient. It would be handy
> if I could simply add a [!] cookie (similar to [/] or [%] cookies) to
> the headline to show the last note taken for this task. Then, I could
> easily see the reason why the task is blocked or what I am supposed to
> do with the task right in agenda view or in the folded headline.
> Something like the following
>
> ** HOLD [!] make babel support org... :HOLD:
> :LOGBOOK:
> - State "HOLD"   from "NEXT"  [2020-08-10 Mon 15:16] \\
>   Finish the text prop org-mode
> - Refiled on [2020-07-20 Mon 17:15]
> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
> :END:
>
> The cookie would be replaced by the last note text, according to
> user-defined format (say, "[%s] |"):
>
> ** HOLD [Finish the text prop org-mode] | make babel support org... :HOLD:
> :LOGBOOK:
> - State "HOLD"   from "NEXT"  [2020-08-10 Mon 15:16] \\
>   Finish the text prop org-mode
> - Refiled on [2020-07-20 Mon 17:15]
> CLOCK: [2020-07-20 Mon 16:53]--[2020-07-20 Mon 16:54] =>  0:01
> :END:
>
> What do you think?
>
> Best,
> Ihor


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

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


signature.asc
Description: PGP signature


[APPLIED] Re: [PATCH] I updated patch by deleteing duplicate tags

2021-01-13 Thread Christopher Miles

Kyle Meyer  writes:

> Christopher Miles writes:
>
>> Subject: [PATCH] org.el: Complete tags from both global and buffer local
>
> Thanks.  Applied (86ad8d279)...
>
>> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
>> index 5e5f1954d..0c9bb99d3 100644
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>> @@ -149,6 +149,13 @@ Example:
>>  A new =u= mode flag for Calc formulas in Org tables has been added to
>>  enable Calc units simplification mode.
>>  
>> +*** =org-set-tags-command= select tags from 
>> ~org-global-tags-completion-table~
>> +
>> +Let ~org-set-tags-command~ TAB fast tag completion interface complete
>> +tags including from both buffer local and user defined persistent
>> +global list (~org-tag-alist~ and ~org-tag-persistent-alist~). Now
>> +option ~org-complete-tags-always-offer-all-agenda-tags~ is horored.
>
> ... adding another space before "Now"

Is there any good solution to auto suitable sentence end of one space or two
space configuration?

> and s/horored/honored/.

Sorry about the typo, being busy, so a little bit of rush.

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

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


signature.asc
Description: PGP signature


Re: [PATCH] I updated patch by deleteing duplicate tags

2021-01-13 Thread Christopher Miles

Kyle Meyer  writes:

> Christopher Miles writes:
>
>> Kyle Meyer  writes:
>>
>>> stardiviner writes:
>>>>> By this patch, will merge both buffer-local tags and user defined global
>>>>> `org-tags-alist`.
>>>
>>> It does a bit more than that.  It uses org-global-tags-completion-table,
>>> which considers tags in all agenda files by default and takes into
>>> account org-tag-alist (as well as org-tag-persistent-alist) via the use
>>> of the org-current-tag-alist variable.
>>
>> That's what I want. Why obviously user pre-defined tags can't be used 
>> globally.
>> Right? It should be.
>
> My point was that it's not just adding these pre-defined lists (#1);
> it's also adding tags from agenda files (#2).  I think we certainly
> don't want to do #2 unconditionally.  On the other hand, #1 is probably
> okay, but as I said in my last email, I could see not wanting that
> either.
>
> Anyway, the patch I proposed (which you've adapted for your latest
> round), avoids #2 by guarding the behavior behind the existing
> org-complete-tags-always-offer-all-agenda-tags option, and I think
> that's a good path forward.
>
>> Subject: [PATCH] org.el: Complete tags from both global and buffer local
>>
>> * lisp/org.el (org-fast-tag-selection): Merge buffer local tags with
>> global alist of tags. And it obey the option
>> org-complete-tags-always-offer-all-agenda-tags.
>
> s/obey/&s/

Applied.

>
>> * doc/org-manual.org: Update the TAB key doc in tags selection UI.
>>
>> * etc/ORG-NEWS: Mention the change in org-set-tags-command.
>> ---
>>  doc/org-manual.org |  6 +++---
>>  etc/ORG-NEWS   |  5 +
>>  lisp/org.el| 24 ++--
>>  3 files changed, 22 insertions(+), 13 deletions(-)
>>
>> diff --git a/doc/org-manual.org b/doc/org-manual.org
>> index b015b502c..01cec4b8d 100644
>> --- a/doc/org-manual.org
>> +++ b/doc/org-manual.org
>> @@ -4860,9 +4860,9 @@ In this interface, you can also use the following 
>> special keys:
>>  
>>#+kindex: TAB
>>Enter a tag in the minibuffer, even if the tag is not in the
>> -  predefined list.  You can complete on all tags present in the
>> -  buffer.  You can also add several tags: just separate them with
>> -  a comma.
>> +  predefined list.  You can complete on all tags present in the buffer
>> +  and globally pre-defined tags from ~org-tag{-persistent}-alist~.
>
> Please spell these two options out: ~org-tag-alist~ and
> ~org-tag-persistent-alist~.

Applied.

>
>> +  You can also add several tags: just separate them with a comma.
>>  
>>  - {{{kbd(SPC)}}} ::
>>  
>> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
>> index 5e5f1954d..5e68d27c0 100644
>> --- a/etc/ORG-NEWS
>> +++ b/etc/ORG-NEWS
>> @@ -149,6 +149,11 @@ Example:
>>  A new =u= mode flag for Calc formulas in Org tables has been added to
>>  enable Calc units simplification mode.
>>  
>> +*** =org-set-tags-command= select tags from 
>> ~org-global-tags-completion-table~
>> +
>> +Let =org-set-tags-command= complete tags from global tags list (both
>> +buffer-local tags and ~org-tag{-persistent}-alist~).
>
> Same note about avoiding shorthand for the option names.

Applied.

>
> Also, please rewrite this to make it clear that this is relevant for TAB
> in the fast completion interface.  It's probably also worth mentioning
> that org-complete-tags-always-offer-all-agenda-tags is now honored.
>
> And, very minor, but any reason for the mix of =...= and ~...~ markup
> here?

Maybe our recognition is different I personally like to markup command as
verbatim, and option as code to display as two different face color. I forget to
drop my habit Now fixed to use "~code~".

>
>> diff --git a/lisp/org.el b/lisp/org.el
>> index 5b0ae389c..ba816dfa6 100644
>> --- a/lisp/org.el
>> +++ b/lisp/org.el
>> @@ -12139,7 +12139,7 @@ (defun org-fast-tag-selection (current inherited 
>> table &optional todo-table)
>>fulltable
>>   (buf (current-buffer))
>>   (expert (eq org-fast-tag-selection-single-key 'expert))
>> - (buffer-tags nil)
>> + (tab-tags nil)
>>   (fwidth (+ maxlen 3 1 3))
>>   (ncol (/ (- (window-width) 4) fwidth))
>>   (i-face 'org-done)
>> @@ -12274,16 +12274,20 @@ (defun org-fast-tag-selection (current inherited 
>> table &optional todo-table)
>>  (setq current nil)
>&

Re: [PATCH] I updated patch by deleteing duplicate tags

2021-01-10 Thread Christopher Miles

Kyle Meyer  writes:

> Thanks for the patch.
>
> stardiviner writes:
>
>> On Wed, Dec 2, 2020 at 5:30 PM stardiviner  wrote:
>>
>>> The default [C-c C-q] completing tags only retrieve tags from current
>>> buffer locally.
>>>
>>> By this patch, will merge both buffer-local tags and user defined global
>>> `org-tags-alist`.
>
> It does a bit more than that.  It uses org-global-tags-completion-table,
> which considers tags in all agenda files by default and takes into
> account org-tag-alist (as well as org-tag-persistent-alist) via the use
> of the org-current-tag-alist variable.
>

That's what I want. Why obviously user pre-defined tags can't be used globally.
Right? It should be.

>>> This is more reasonable.
>
> I'd guess that depends on the user.  I personally wouldn't like to see
> tags from all of my agenda files, and I'm fine not seeing
> org-tag{-persistent}-alist ones that aren't in the current buffer given
> that they have fast selection keys.

Currently tags selection is now slow, even with 100 pre-defined tags. Should be
fine. Tags sometimes is abundant. So if it is slow, then it means the command
=org-set-tags-command= should be optimized.

>
>> Subject: [PATCH] org.el: Complete tags from both global and buffer local
>>
>> * lisp/org.el: (org-fast-tag-selection): merge buffer local tags with
>> global alist of tags.
>
> Convention/consistency nits: spurious ":" after ".el" and
> s/merge/Merge/.

Updated. Thanks

>
>> ---
>>  lisp/org.el | 11 +++
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/lisp/org.el b/lisp/org.el
>> index 0e12e4b15..287b8c407 100644
>> --- a/lisp/org.el
>> +++ b/lisp/org.el
>> @@ -12256,10 +12256,13 @@ (defun org-fast-tag-selection (current inherited 
>> table &optional todo-table)
>>  (condition-case nil
>>  (setq tg (completing-read
>>"Tag: "
>> -  (or buffer-tags
>> -  (with-current-buffer buf
>> -(setq buffer-tags
>> -  (org-get-buffer-tags))
>> +  (delq nil
>> +(delete-dups
>> + (append (or buffer-tags
>> + (with-current-buffer buf
>> +   (setq buffer-tags
>> + 
>> (org-get-buffer-tags
>> + 
>> (org-global-tags-completion-table))
>
> This change in behavior should come with a NEWS entry and a
> documentation update.  What the manual currently says is now stale:
>
>   - {{{kbd(TAB)}}} ::
>   
> #+kindex: TAB
> Enter a tag in the minibuffer, even if the tag is not in the
> predefined list.  You can complete on all tags present in the
> buffer.  You can also add several tags: just separate them with
> a comma.
>
> As I mentioned above, though, I'm not sure always adding agenda tags is
> desirable.  However, I think it'd probably be safe to look at
> org-complete-tags-always-offer-all-agenda-tags as an indication of
> whether the user wants this behavior.  org-set-tags-command already
> considers that option when it generates the table that it passes to
> org-fast-tag-selection.  So perhaps we could just consider the table
> when calling completing-read for the tab key (something along the lines
> of the patch at the end of the email).
>

Indeed, I add condition on ~org-complete-tags-always-offer-all-agenda-tags~ now.

> Conceptually that's been discussed/tried before, but it was then backed
> out of:
>
>   * 
> https://orgmode.org/list/f753e612-2d5d-4ba7-af0c-d49c7a8dd...@pobox.com/T/#u
>   * 647396464 (org.el: Include tags from `org-tag-alist' when completing
> with the TAB key, 2012-03-27)
>   * d4ddcbb8b (Revert "org.el: Include tags from `org-tag-alist' when
> completing with the TAB key.", 2012-04-10)
>   * acc7a0b2b (org.el: Include `org-tag-alist' in the list for tag
> completions, 2012-03-27)
>

I checked this mailing list thread, the original commit use ~(mapcar 'car 
table)~.
It's more simple. I updated my code to this.

My patch only changed the ~completing-read~ part. And I found ido support option
is been removed in Org. I think this is right decision.

> At a quick glance, I think the patch below avoids the problems that led
> to 647396464 being reverted, but that'd need to be checked more
> carefully.
>
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 5b0ae389c..9383719e3 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -12139,7 +12139,7 @@ (defun org-fast-tag-selection (current inherited 
> table &optional todo-table)
> fulltable
>(buf (current-buffer))
>(expert (eq org-fast-tag-selection-single-key 'expert))
> -  (buffer-tags nil

Re: [BUG] [C-u C-u C-c C-o] open link with external program auto exited before child process open file

2021-01-10 Thread Christopher Miles

I tested with following code:

#+begin_src emacs-lisp
(let ((cmd (format
"%s %s"
"xdg-open"
(shell-quote-argument
 (expand-file-name
  "~/Downloads/伦敦底层社会 1,2章.doc")
  (start-process-shell-command cmd "*org-open-file*" cmd))

(start-process "org-open-file"
   " *org-open-file*"
   "xdg-open"
   (expand-file-name "~/Downloads/伦敦底层社会 1,2章.doc"))
#+end_src

Both has same problem, xdg-open exited automatically and before really open 
file.

So maybe I should ask question in Emacs-help mailing list? Because this problem
seems on ~start-process~ / ~start-process-shell-command~.

Christopher M. Miles  writes:

> I found exactly same problem and some answer on this question:
>
> https://askubuntu.com/questions/646631/emacs-doesnot-work-with-xdg-open
>
> But I hope Org Mode can provide solution by default. Based on the description 
> in
> answers. Is there something Org Mode can do to get around this problem?
>
> Nicolas Goaziou  writes:
>
>> Hello,
>>
>> stardiviner  writes:
>>
>>> When I press =[C-u C-u C-c C-o]= to open an image file link with system 
>>> external
>>> program. It can't open the image file.
>>
>> Is it really an Org bug? I.e., is your mailcap file properly set up?
>>
>> If you think this is really an Org bug, could you provide an ECM,
>> including your .mailcap?
>>
>> Regards,


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

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


signature.asc
Description: PGP signature


Re: [BUG] [C-u C-u C-c C-o] open link with external program auto exited before child process open file

2021-01-10 Thread Christopher Miles

I found exactly same problem and some answer on this question:

https://askubuntu.com/questions/646631/emacs-doesnot-work-with-xdg-open

But I hope Org Mode can provide solution by default. Based on the description in
answers. Is there something Org Mode can do to get around this problem?

Nicolas Goaziou  writes:

> Hello,
>
> stardiviner  writes:
>
>> When I press =[C-u C-u C-c C-o]= to open an image file link with system 
>> external
>> program. It can't open the image file.
>
> Is it really an Org bug? I.e., is your mailcap file properly set up?
>
> If you think this is really an Org bug, could you provide an ECM,
> including your .mailcap?
>
> Regards,


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

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


signature.asc
Description: PGP signature


Re: temporary inclusion of a read-only file / inline element into orgmode buffer

2021-01-06 Thread Christopher Miles

Tom Gillespie writes:

> Check out org-transclusion, it covers some of the use cases you
> describe or could be used to implement them. The issue with giant
> results, especially those that have very long lines, is more
> challenging, but being able to specify that different output streams
> should go to files instead of results might be a start, or having them
> go to a file and having process do the equivalent of tail on the file
> to continually update the results stream of the buffer would be really
> useful (if it could be done without disrupting other editing flows.
> The shortest path to splitting file vs buffer would probably be to
> decorate org-bable-insert-result (in ob-core.el) to detect the size of
> the result and write the full result to a separate buffer if it is
> beyond the limit you set. Best,
> Tom
>
> https://github.com/nobiot/org-transclusion

This package is interesting, I want to use it in my package org-link-beautify
for previewing text file etc.

https://github.com/stardiviner/org-link-beautify

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

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


signature.asc
Description: PGP signature


Re: [PATCH] I updated patch by deleteing duplicate tags

2021-01-06 Thread Christopher Miles

Bump this thread. Any ideas about this functionality? Any objection or 
suggestion?

stardiviner  writes:

> [stardiviner] GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter:  @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
> On Wed, Dec 2, 2020 at 5:30 PM stardiviner  wrote:
>
>> The default [C-c C-q] completing tags only retrieve tags from current
>> buffer locally.
>>
>> By this patch, will merge both buffer-local tags and user defined global
>> `org-tags-alist`.
>>
>> This is more reasonable.
>>
>>
>> [stardiviner] GPG key ID: 47C32433
>> IRC(freeenode): stardiviner Twitter:  @numbchild
>> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
>> Blog: http://stardiviner.github.io/
>>


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

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


signature.asc
Description: PGP signature