Re: Custom Bulk Functions With Prompt

2021-01-19 Thread Ihor Radchenko
Kevin Foley  writes:

> '((?R (set-category set-category-args))
>   (?C bulk-cut))
>
> I mostly went with this because I'm not very familiar with `pcase'.
> I've confirmed it works as expected but let me know if you still think
> another approach is better.

I understand now. I thought you wanted to use different format:
(?R set-category set-category-args)

Then, your code looks reasonable. Just need to document the new custom
bulk action format.

Best,
Ihor



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: logrepeat only logging LAST_REPEAT

2021-01-19 Thread Ihor Radchenko
Michael Heerdegen  writes:

> Is there a way to get only the :LAST_REPEAT: prop logged, without the
> ever-growing list?

I guess you can try to play with org-log-done and org-log-repeat variables.

Best,
Ihor



Re: Region-based meta-notes

2021-01-19 Thread Ihor Radchenko
Lawrence Bottorff  writes:

> So yes, simply being able to select regions and make side notes about them
> could give you a very fine level of control over metadata in a file. Is
> there such a thing in the Emacs/org-mode world?

I use inlinetasks for this. You can add notes to inlinetask just as you
add notes to a normal headline. Also, inlinetasks can be created around
active region:

Signature
(org-inlinetask-insert-task  NO-STATE)

Documentation
Insert an inline task.

If prefix arg NO-STATE is set, ignore org-inlinetask-default-state.
If there is a region wrap it inside the inline task.

Key Bindings
org-mode-map C-c C-x t

Best,
Ihor




Re: How can I keep Org-id links from breaking when moving files?

2021-01-19 Thread Samuel Wales
(defvar org-id-locations nil
  "List of files with IDs in those files.")

(defvar org-id-files nil
  "List of files that contain IDs.")

you are in a maze of twisty little passages.

you are in a twisty maze of little passages.


On 1/19/21, doltes  wrote:
>
> aroz...@gmail.com writes:
>
>> This question is in the context of using Org-id UUIDs for linking between
>> files. If I understand correctly, Org-id knows where to look for UUIDs
>> (generated by org-id-get-create) by looking at the org-id-locations
>> variable. But what if I move an .org file that I've generated a UUID into
>> another folder? I know I can run org-id-update-id-locations, and there's
>> an
>> org-id-extra-files variable, but is there a way to list all the folders
>> on
>> the system where Org-id should look for UUIDs?
>>
>> Thanks,
>> Alan
>
> After reading the docstring of the function
> =org-id-update-id-locations=, I found that the files which are scanned
> are defined by 6 variables.
>
> The following was retrieved from the docstring
>
> #+begin_quote
> This will scan all agenda files, all associated archives, and all
> files currently mentioned in ‘org-id-locations’.
> #+end_quote
>
> This implies that when that function is executed, the files whose
> content is searched for IDs (i.e. they are scanned) are
>
> + The files mentioned in =org-agenda-files=.
> + The archives associated to the files in =org-agenda-files=.
> + The files mentioned in =org-id-locations=.
> + The files provided as arguments to the =org-id-update-id-locations=.
>
> The following are not mentioned in the documentation of
> =org-id-update-id-locations=, but when looking at the source code, you
> can see that the value of the following variables is used
>
> + =org-id-extra-files=
> + =org-id-files=
>
> As we could see, the files which are scanned are defined by 6 variables.
>
> Now, apparently, you want to get a list of the files which are
> scanned. You can do that by executing what
> =org-id-update-id-locations= executes in order to get the list of
> files to scan. The following was retrieved from that function with
> some modifications
>
> #+begin_src elisp :results output
> (let ((files (delete-dups
>  (mapcar #'file-truename
>  (append
>   (org-agenda-files t org-id-search-archives)
>   (unless (symbolp org-id-extra-files)
> org-id-extra-files)
>   org-id-files)
>   (dolist (file files) (princ (format "%s\n" file
> #+end_src
>
> #+RESULTS:
> #+begin_example
> /home/username/my/org/Statistics.org
> /home/username/my/org/Programming languages/Elisp.org
> /home/username/my/org/Programming languages/R.org
> #+end_example
>
> Hope that helps. Let me know if that answers your question.
>
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html



Re: Region-based meta-notes

2021-01-19 Thread Juan Manuel Macías
Hello,

Lawrence Bottorff  writes:

> So yes, simply being able to select regions and make side notes about
> them could give you a very fine level of control over metadata in a
> file. Is there such a thing in the Emacs/org-mode world?

Take a look at the org-marginalia package:

https://github.com/nobiot/org-marginalia

Regards,

Juan Manuel




Region-based meta-notes

2021-01-19 Thread Lawrence Bottorff
I've got this

* foldl
:PROPERTIES:_

Problematic with ~foldr~ is that it recurses out to its full length
before performing the given function's task. For example, with

#+begin_example
foldr (+) list
#+end_example

~(+)~ behaves strictly, meaning that both arguments to it must be
fully evaluated before ~(+)~ can return a result. Hence, for
...

Problem is I've borrowed (some, most, all of) this from an online source
and I want to credit the source. What would be nice is to be able to select
a region -- however big or small -- and create a log/note/footnote etc.
about the selected region -- in my case, give reference.

Of course I could just tack a footnote at the end of the borrowed stuff,
but then in the case of multiple preceding paragraphs, formulae, etc. it
would be hard to indicate where the particular borrowed parts began --
without resorting to ugly marker kludges.

So yes, simply being able to select regions and make side notes about them
could give you a very fine level of control over metadata in a file. Is
there such a thing in the Emacs/org-mode world?

LB


Regression in org-element-fixed-width-parser? Extra newline added after exported block

2021-01-19 Thread General discussions about Org-mode.
Hi all,

I wrote two Org exporters[1,2] that each have a testsuite of their own.
I regularly run tests against Emacs 25 and 26 with their respective
Org versions.  When I started to test against Emacs 27.1 with Org mode
9.3 I got test failures in both exporters:  The export of a fixed with
block now contains an extra empty line after the block.


I have created a minimal test using the ox-ascii backend that shows
the same behaviour in Org core.  Using git bisect, I have tracked the
source of the extra line down to this change:

  commit 7d9e4da447fa54633daf75a241c6b0a603c0e662
  Prevent spurious newline character in fixed-width area value

The commit changes the newline handling _within_ the fixed-width block
(proven by test-org-element/fixed-width-parser which is updated in
respect to the changes).  But the existing test only covers the
fixed-width block itself.  It does not extend to the next paragraph
after the block and so does not see the additional empty line that has
popped up.


My test that fails on the extra line is attached here.  When run on
against a checkout earlier than 7d9e4da44 the test succeeds, after
that it fails.


Is the extra newline a regression?

I have looked at the changes in `org-element-fixed-width-parser', but
I don't understand where the extra newline comes from as I don't
really grok the parsing routine.

I'd love to help track this down.  If my patch is deemed useful to
prevent further changes to the parser then feel free to apply it.

Best regards
Christian


[1] https://github.com/mmitch/ox-s9y
[2] https://github.com/mmitch/ox-bb
I intend to submit ox-bb as a patch later, but I currently have
a failing test in its testsuite ;-)
-- 
Christian.Garbshttps://www.cgarbs.de

How hard can it be?



Re: How can I keep Org-id links from breaking when moving files?

2021-01-19 Thread doltes


aroz...@gmail.com writes:

> This question is in the context of using Org-id UUIDs for linking between
> files. If I understand correctly, Org-id knows where to look for UUIDs
> (generated by org-id-get-create) by looking at the org-id-locations
> variable. But what if I move an .org file that I've generated a UUID into
> another folder? I know I can run org-id-update-id-locations, and there's an
> org-id-extra-files variable, but is there a way to list all the folders on
> the system where Org-id should look for UUIDs?
>
> Thanks,
> Alan

After reading the docstring of the function
=org-id-update-id-locations=, I found that the files which are scanned
are defined by 6 variables.

The following was retrieved from the docstring

#+begin_quote
This will scan all agenda files, all associated archives, and all
files currently mentioned in ‘org-id-locations’.
#+end_quote

This implies that when that function is executed, the files whose
content is searched for IDs (i.e. they are scanned) are

+ The files mentioned in =org-agenda-files=.
+ The archives associated to the files in =org-agenda-files=.
+ The files mentioned in =org-id-locations=.
+ The files provided as arguments to the =org-id-update-id-locations=.

The following are not mentioned in the documentation of
=org-id-update-id-locations=, but when looking at the source code, you
can see that the value of the following variables is used

+ =org-id-extra-files=
+ =org-id-files=

As we could see, the files which are scanned are defined by 6 variables.

Now, apparently, you want to get a list of the files which are
scanned. You can do that by executing what
=org-id-update-id-locations= executes in order to get the list of
files to scan. The following was retrieved from that function with
some modifications

#+begin_src elisp :results output
(let ((files (delete-dups
   (mapcar #'file-truename
   (append
(org-agenda-files t org-id-search-archives)
(unless (symbolp org-id-extra-files)
  org-id-extra-files)
org-id-files)
  (dolist (file files) (princ (format "%s\n" file
#+end_src

#+RESULTS:
#+begin_example
/home/username/my/org/Statistics.org
/home/username/my/org/Programming languages/Elisp.org
/home/username/my/org/Programming languages/R.org
#+end_example

Hope that helps. Let me know if that answers your question.



Re: Custom Bulk Functions With Prompt

2021-01-19 Thread Kevin Foley
Ihor Radchenko  writes:

> You need to add extra matcher `(,_ ,argf ,f).

My idea is to keep allow the user to optionally pass a list of argf and
f instead of just a function.

For example if no args need to be collected:

'((?R set-category)
  (?C bulk-cut))

but if arguments needs to be collected for set-category:

'((?R (set-category set-category-args))
  (?C bulk-cut))

I mostly went with this because I'm not very familiar with `pcase'.
I've confirmed it works as expected but let me know if you still think
another approach is better.

Kevin



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

2021-01-19 Thread Maxim Nikulin

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.
diff --git a/lisp/org.el b/lisp/org.el
index 5b1443c4e..299f39949 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8743,29 +8743,34 @@ If the file does not exist, throw an error."
 (cond
  ((and (stringp cmd) (not (string-match "^\\s-*$" cmd)))
   ;; Remove quotes around the file name - we'll use shell-quote-argument.
-  (while (string-match "['\"]%s['\"]" cmd)
-	(setq cmd (replace-match "%s" t t cmd)))
-  (setq cmd (replace-regexp-in-string
-		 "%s"
-		 (shell-quote-argument (convert-standard-filename file))
-		 cmd
-		 nil t))
-
-  ;; Replace "%1", "%2" etc. in command with group matches from regex
-  (save-match-data
-	(let ((match-index 1)
-	  (number-of-groups (- (/ (length link-match-data) 2) 1)))
-	  (set-match-data link-match-data)
-	  (while (<= match-index number-of-groups)
-	(let ((regex (concat "%" (number-to-string match-index)))
-		  (replace-with (match-string match-index dlink)))
-	  (while (string-match regex cmd)
-		(setq cmd (replace-match replace-with t t cmd
-	(setq match-index (+ match-index 1)
-
-  (save-window-excursion
-	(message "Running %s...done" cmd)
-	(start-process-shell-command cmd nil cmd)
+  (let* ((command (split-string-and-unquote cmd))
+	 (command (mapcar (lambda (arg)
+(while (string-match "['\"]%s['\"]" arg)
+   (setq arg (replace-match "%s" t t arg)))
+arg)
+			  command)))
+	;; Replace "%1", "%2" etc. in command with group matches from regex
+	(save-match-data
+	  (let ((match-index 1)
+		(number-of-groups (- (/ (length link-match-data) 2) 1)))
+	(set-match-data link-match-data)
+	(while (<= match-index number-of-groups)
+		   (let ((regex (concat "%" (number-to-string match-index)))
+			 (replace-with (match-string match-index dlink)))
+		 (setq command
+			   (mapcar (lambda (arg)
+ (while (string-match regex arg)
+	(setq arg (replace-match replace-with t t arg)))
+ arg)
+   command)))
+		   (setq match-index (+ match-index 1)
+	(setq command (mapcar (lambda (arg) (format-spec arg (list (cons ?s file command))
+	(save-window-excursion
+	  (message "Running %S...done" command)
+	  (make-process :name "org-open-file" :connection-type 'pipe
+			:buffer "*Messages*"
+			:filter (lambda (proc string) (message "org-open-file: %s" string))
+			:noquery 't :command command))
 	(and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait
  ((or (stringp cmd)
 	  (eq cmd 'emacs))


Re: Why are (UU)IDs limited to the headline level?

2021-01-19 Thread arozbiz
That was my thought as well.

On Mon, Jan 18, 2021 at 8:02 PM Ihor Radchenko  wrote:

> "Dr. Arne Babenhauserheide"  writes:
>
> > You can use <> to make it possible to link to any
> > place in a document.
>
> It does not work globally though. One cannot just put
> [[id:some-anchor-name]] link in other file.
>
> Best,
> Ihor
>
>


logrepeat only logging LAST_REPEAT

2021-01-19 Thread Michael Heerdegen
Hello,

for some entries I use the logrepeat feature (enabled by setting the
LOGGING property of the entry).

I get a :LAST_REPEAT: property that I (always) want, and also a complete
log I do not (always) want, in the form of a growing list of

- State "DONE" from "XYZ" [2021-01-19 Di 12:01]

style entries that I often "garbage collect" manually.

Is there a way to get only the :LAST_REPEAT: prop logged, without the
ever-growing list?

If not, please consider as "wishlist" request.

TIA,

Michael.