Re: org-refile-use-cache and jumps using org-refile or org-goto

2021-03-02 Thread Samuel Wales
idk if thi will help buit a fwe not3es.  just in case they are
relevant to your case.

fwiw i have not heard of interactions between org-goto and the refile
mechanism and the cache.  i hafve not heard that the latter used a
cache but i do not use it.  refile with and withoyut the goto prefix
should normatively be congruent and both use cache.

i used to use the refile cache, then discovered that ido-hacks sped
ido so much that i didn't need it.  it would cache one fileset and
then be potentially not usable for another.  sort of like one cache
and multiple callers.  idk if htat got fixed.  probably not used much.

until recently in maint, ido and ido hacks with both refile and refile
goto [note: org-refile with a goto arg, not org-goto] has worked
perfectly.  with no cache.  now, there is an issue, where with no
cache that i know of, the first use, or the first use in a long time,
will actually present a huge file list that includes crazy elements
and is not constrained by even the verify function.  thus if i type
faster than it goes, the wrong item gets selected.  even if i use the
same selectors as normal.  so there's some bug or race condition.  it
is slow at those times.  this might not be relevant to your case but
seems worth mentioning.  i think i have not filed a bug report as i
don't know how to repro it at this time.


On 3/2/21, Maxim Nikulin  wrote:
> It seems, something goes a bit wrong. However it is rather confusion
> than anything really broken.
>
> Maybe everybody uses helm, ivy, etc., so nobody is affected.
>
> Usually I jump from one note to another heading with C-u C-c C-j
> (org-goto interface with target completion). I have not setup helm or
> other similar package. Completion works, maybe it is not really perfect
> (e.g. completion of top-level headings and deeper ones differ a bit). I
> have heard that C-u C-c C-w (org-refile) could work in a similar way. I
> did not like the latter variant due to mandatory file name in the
> beginning of a target.
>
> I have tried to enable org-refile-use-cache. Now completion options
> depends on what method was called earlier: org-refile or org-goto. If
> after cache clean up (C-u C-u C-u C-c C-w) first command was C-u C-c C-j
> (org-goto) than there is no file name as a prefix for both commands.
> However file name is prepended for both C-u C-c C-j and C-u C-c C-w if
> at first org-refile was called.
>
> There is one issue however. Default option option does not work if after
> cache clean other command is called, e.g.
> - jump using C-u C-c C-j
> - clean cache C-u C-u C-u C-c C-w
> - try to jump or to refile [C-u] C-c C-w to default offered option
> - "user-error: Invalid target location"
>
> I have just one file in the org-agenda-files list. It is becoming
> larger, that is why I decided to try org-refile-use-cache. My
> customization is minimal (besides org-default-dir and org-agenda-files):
>
> (org-refile-targets (quote ((org-agenda-files :maxlevel . 5
> (org-outline-path-complete-in-steps nil)
>
> I have tried to add (nil :maxlevel . 5) to org-refile-targets to check
> if options without file name will appear in addition to ones with file
> name for org-refile, but it has not happened. It was not clear at first
> that it is possible to start query with "/" and file name is added when
> TAB is pressed.
>
> Is it expected that with cache enabled, command that causes cache update
> affects appearance of completion options to its sibling (org-refile and
> org-goto)?
>
>
>


-- 
The Kafka Pandemic

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



Re: Org mode links: Open a PDF file at a given page and highlight a given string

2021-03-02 Thread Juan Manuel Macías
Hi Rodrigo,

Rodrigo Morales  writes:

> I want to be able to
>
> + create a Org link to specific pages of a PDF. I've managed to
>   accomplish this by setting the following value.
> [ ... ]
> + create a Org link to specific pages of a PDF and highlight a given
>   string.

A possible alternative, which gives you more control over the link, is
`org-link-set-parameters'. For example:

#+begin_src emacs-lisp
  (org-link-set-parameters
   "pdf-pag"
   :follow (lambda (path)
 (let ((pag (if (string-match "::\\([1-9]+\\):*:*\\(.*\\)" path)
(match-string 1 path)
  (error "no pages")))
   (clean-path (expand-file-name (replace-regexp-in-string 
"::.+" "" path)))
   (str (when (string-match "::\\([1-9]+\\)::\\(.+\\)" path)
  (match-string 2 path
   (start-process-shell-command "zathura" nil (concat "zathura "
  clean-path
  " -P "
  pag
  (when str
(format " 
-f '%s' " str)))
#+end_src

And then:

#+begin_src org
  [[pdf-pag:~/Downloads/grub.pdf::95::do]]
#+end_src

Best regards,

Juan Manuel 



Re: [PATCH] Query when exiting with running clock

2021-03-02 Thread Allen Li
On Wed, Feb 3, 2021 at 5:45 AM Kyle Meyer  wrote:
>
> Allen Li writes:
>
> > This is a patch adding a query function when exiting Emacs, warning the
> > user if there is a running clock.  This is useful for preventing the
> > user from accidentally leaving dangling clocks.  I have had success
> > using a modified personal version of this code.
>
> Thanks.  I'd find this useful as well.

Thanks for your feedback.  I have addressed your comments.  Please see
the new patches.
From e2fa281ca3d5c58fd759011c5f93790f49cb669d Mon Sep 17 00:00:00 2001
From: Allen Li 
Date: Tue, 12 Jan 2021 00:33:32 -0800
Subject: [PATCH 2/2] org-clock: Query when exiting with running clock

It's annoying to accidentally quit Emacs with a running clock, then
resolve the clock the next time when Emacs is started.

* lisp/org-clock.el (org-clock-kill-emacs-query): New function.
(org-clock-ask-before-exiting): New user option.
---
 lisp/org-clock.el | 21 +
 1 file changed, 21 insertions(+)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 2a6a9af47..52b486cd8 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -485,6 +485,16 @@ is added to the user configuration."
 	  (integer :tag "Clock out after Emacs is idle for X seconds")
 	  (const :tag "Never auto clock out" nil)))
 
+(defcustom org-clock-ask-before-exiting t
+  "If non-nil, ask if the user wants to clock out before exiting Emacs.
+  This variable only has effect if set with \\[customize]."
+  :set (lambda (symbol value)
+ (if value
+ (add-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query)
+   (remove-hook 'kill-emacs-query-functions #'org-clock-kill-emacs-query))
+ (set symbol value))
+  :type 'boolean)
+
 (defvar org-clock-in-prepare-hook nil
   "Hook run when preparing the clock.
 This hook is run before anything happens to the task that
@@ -3096,6 +3106,17 @@ The details of what will be saved are regulated by the variable
 	   (when (org-invisible-p) (org-show-context))
 	(_ nil)
 
+(defun org-clock-kill-emacs-query ()
+  "Query user when killing Emacs.
+This function is added to `kill-emacs-query-functions'."
+  (let ((buf (org-clock-buffer)))
+(when (and buf (yes-or-no-p "Clock out and save? "))
+  (with-current-buffer buf
+(org-clock-out)
+(save-buffer
+  ;; Unconditionally return t for `kill-emacs-query-functions'.
+  t)
+
 ;; Suggested bindings
 (org-defkey org-mode-map "\C-c\C-x\C-e" 'org-clock-modify-effort-estimate)
 
-- 
2.30.1

From 429dd06ac281a5706c8ce2f3e35dab4aab6b5bfc Mon Sep 17 00:00:00 2001
From: Allen Li 
Date: Tue, 12 Jan 2021 00:26:47 -0800
Subject: [PATCH 1/2] org-clock: Replace org-clocking-buffer with
 org-clock-is-active

org-clocking-buffer and org-clock-is-active have the same definition.
org-clocking-buffer is defined in org-clock.el while
org-clock-is-active is defined in org.el.  org-clock.el requires
org.el.

org-clocking-buffer is kept as an alias to preserve backward
compatibility with any user code.

* lisp/org-clock.el (org-clocking-buffer): Moved to org.el.
* lisp/org.el (org-clocking-buffer): Moved function.
(org-clock-is-active): Made into an alias.
---
 lisp/org-clock.el | 4 
 lisp/org.el   | 6 +++---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index c94f60781..2a6a9af47 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -607,10 +607,6 @@ cannot be translated."
 	  ((stringp drawer) drawer)
 	  (t nil
 
-(defun org-clocking-buffer ()
-  "Return the clocking buffer if we are currently clocking a task or nil."
-  (marker-buffer org-clock-marker))
-
 (defun org-clocking-p ()
   "Return t when clocking a task."
   (not (equal (org-clocking-buffer) nil)))
diff --git a/lisp/org.el b/lisp/org.el
index fd6226702..e35c19a9e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -144,7 +144,6 @@ Stars are put in group 1 and the trimmed body in group 2.")
 (declare-function org-clock-timestamps-down "org-clock" ( n))
 (declare-function org-clock-timestamps-up "org-clock" ( n))
 (declare-function org-clock-update-time-maybe "org-clock" ())
-(declare-function org-clocking-buffer "org-clock" ())
 (declare-function org-clocktable-shift "org-clock" (dir n))
 (declare-function org-columns-quit "org-colview" ())
 (declare-function org-columns-insert-dblock "org-colview" ())
@@ -3828,10 +3827,11 @@ This is needed for font-lock setup.")
   "Marker recording the last clock-in, but the headline position.")
 (defvar org-clock-heading ""
   "The heading of the current clock entry.")
-(defun org-clock-is-active ()
+(defun org-clocking-buffer ()
   "Return the buffer where the clock is currently running.
 Return nil if no clock is running."
   (marker-buffer org-clock-marker))
+(defalias 'org-clock-is-active #'org-clocking-buffer)
 
 (defun org-check-running-clock ()
   "Check if the current buffer contains the running clock.
@@ -8254,7 +8254,7 @@ function is being called 

Re: Please help by becoming a maintainer for an Org Babel file

2021-03-02 Thread Nick Savage

Hi Bastien,

I'm willing to volunteer to maintain ob-sqlite.el. I think like Andy, I 
have some work to do to get up to speed on my elisp but I'm comfortable 
enough with sqlite itself.


As far as I'm aware my copyright process has been finalized as well.

Thanks,
Nick

On 10/26/20 4:07 AM, Bastien wrote:

Dear all,

we are looking for more maintainers of individual Org Babel files.

Jack and Ian are already in, I added myself to ob-clojure.el.

If you feel like proposing yourself for maintaining an Org Babel
language, that would be super helpful.

Thanks a lot!





Re: ob-reticulate: R+Python interface from Babel

2021-03-02 Thread Jack Kamm
Hi Jeremie,

> Many thanks for this package. It seems like a better way all together
> to manipulate python output.

I don't disagree, at least when it comes to handling dataframes.

This is because ob-reticulate makes the block actually executed with
ob-R.el instead of ob-python.el. R has better built-in support for
manipulating dataframes, which ob-R.el can take advantage of when
handling output.

I tried before to improve ob-python handling of dataframes, plots, and
other results, but the code got a bit messy and I decided to put it on
ice. I may return to it, some day.

Cheers,
Jack



Re: Org mode links: Open a PDF file at a given page and highlight a given string

2021-03-02 Thread Kyle Meyer
Rodrigo Morales writes:

[...]
> + create a Org link to specific pages of a PDF and highlight a given
>   string.
>
> #+begin_src emacs-lisp :results silent
> (setq org-file-apps
>   '(("\\.pdf::\\([0-9]+\\)::\\([^:]+\\)\\'" . "zathura -P %1 -f %2 %s")))
> #+end_src
>
> The following link must open the PDF at a given page and highlight the
> given string. However, I'm getting the following error (see the
> =#+begin_example= block below.)
>
> [[file:~/Downloads/grub.pdf::95::do]]
>
> #+begin_example
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   replace-match(nil t t "zathura -P 95 -f %2 
> /home/username/Downloads/grub")

I haven't looked at this closely or tried to trigger the error, but an
in-flight patch is touching this area
().  I've yet to
revisit it to address Maxim's helpful feedback, but I hope to soon and
will look at this error then too.

Thanks for reporting.



Re: Please help by becoming a maintainer for an Org Babel file

2021-03-02 Thread Andy Klock
"Kyle Meyer"  writes:
 
> While I of course can't speak for Bastien (and am not sure what 
> this thread involved behind the scenes here), it doesn't appear 
> that anyone volunteered for ob-sql.  And regardless any help 
> would be greatly appreciated.

Perfect. I'll see what I can do.
 
> Fwiw here are a couple of the recent-ish ob-sql-related messages 
> that haven't seen any attention: 
> 
> https://orgmode.org/list/CADzxVkEO=x6r_yai3qjkoojipvphxpcfrc2jaw7fpufs92w...@mail.gmail.com
>  
> https://orgmode.org/list/97dfc87b-9748-a5e2-cf4d-1aa784516...@rwth-aachen.de 

Thanks, I'll take a look.

Andy K




Re: Please help by becoming a maintainer for an Org Babel file

2021-03-02 Thread Andy Klock


Hi Bastien,

"Bastien"  writes:
 
> FWIW I do confirm that any help is welcome!  Nobody is ever "too 
> late" in volunteering for maintaining an ob-* file. 

I'm very comfortable with various SQLs and RDBMSs, but my elisp 
could still use some work. I'll see what I can do.

Thanks,

Andy K




Org mode links: Open a PDF file at a given page and highlight a given string

2021-03-02 Thread Rodrigo Morales


I want to be able to

+ create a Org link to specific pages of a PDF. I've managed to
  accomplish this by setting the following value.

#+begin_src emacs-lisp :results silent
(setq org-file-apps
  '(("\\.pdf::\\([0-9]+\\)\\'" . "zathura -P %1 %s")))
#+end_src

The following links open the PDF at the given page.

[[file:~/Downloads/grub.pdf::10]]

[[file:~/Downloads/grub.pdf::20]]

[[file:~/Downloads/grub.pdf::30]]

+ create a Org link to specific pages of a PDF and highlight a given
  string.

#+begin_src emacs-lisp :results silent
(setq org-file-apps
  '(("\\.pdf::\\([0-9]+\\)::\\([^:]+\\)\\'" . "zathura -P %1 -f %2 %s")))
#+end_src

The following link must open the PDF at a given page and highlight the
given string. However, I'm getting the following error (see the
=#+begin_example= block below.)

[[file:~/Downloads/grub.pdf::95::do]]

#+begin_example
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  replace-match(nil t t "zathura -P 95 -f %2 /home/username/Downloads/grub")
  org-open-file("~/Downloads/grub.pdf" nil nil "95::do")
  apply(org-open-file "~/Downloads/grub.pdf" nil (nil "95::do"))
  org-link-open((link (:type "file" :path "~/Downloads/grub.pdf" :format 
bracket :raw-link "file:~/Downloads/grub.pdf::95::do" :application nil 
:search-option "95::do" :begin 821 :end 858 :contents-begin nil :contents-end 
nil :post-blank 0 :parent (paragraph (:begin 821 :end 860 :contents-begin 821 
:contents-end 859 :post-blank 1 :post-affiliated 821 :parent nil nil)
  org-open-at-point(nil)
  funcall-interactively(org-open-at-point nil)
  call-interactively(org-open-at-point nil nil)
  command-execute(org-open-at-point)
#+end_example

Note that the following accomplishes what I'm looking for

#+begin_src bash
zathura -P 95 -f do ~/Downloads/grub.pdf
#+end_src

My question is: How can I get rid of that error so that the PDF is
opened at a given page and the string is highlighted?

PS: If you want a PDF to test the link presented in this message, you
can download the following PDF (564K). It was the smallest PDF in
gnu.org I was able to find.

#+begin_src bash :dir ~/Downloads :results silent
wget 'https://www.gnu.org/software/grub/manual/grub/grub.pdf'
#+end_src

-- 
Greetings,
Rodrigo Morales.

IRC: rdrg109 (freenode)



org-refile-use-cache and jumps using org-refile or org-goto

2021-03-02 Thread Maxim Nikulin
It seems, something goes a bit wrong. However it is rather confusion 
than anything really broken.


Maybe everybody uses helm, ivy, etc., so nobody is affected.

Usually I jump from one note to another heading with C-u C-c C-j 
(org-goto interface with target completion). I have not setup helm or 
other similar package. Completion works, maybe it is not really perfect 
(e.g. completion of top-level headings and deeper ones differ a bit). I 
have heard that C-u C-c C-w (org-refile) could work in a similar way. I 
did not like the latter variant due to mandatory file name in the 
beginning of a target.


I have tried to enable org-refile-use-cache. Now completion options 
depends on what method was called earlier: org-refile or org-goto. If 
after cache clean up (C-u C-u C-u C-c C-w) first command was C-u C-c C-j 
(org-goto) than there is no file name as a prefix for both commands. 
However file name is prepended for both C-u C-c C-j and C-u C-c C-w if 
at first org-refile was called.


There is one issue however. Default option option does not work if after 
cache clean other command is called, e.g.

- jump using C-u C-c C-j
- clean cache C-u C-u C-u C-c C-w
- try to jump or to refile [C-u] C-c C-w to default offered option
- "user-error: Invalid target location"

I have just one file in the org-agenda-files list. It is becoming 
larger, that is why I decided to try org-refile-use-cache. My 
customization is minimal (besides org-default-dir and org-agenda-files):


(org-refile-targets (quote ((org-agenda-files :maxlevel . 5
(org-outline-path-complete-in-steps nil)

I have tried to add (nil :maxlevel . 5) to org-refile-targets to check 
if options without file name will appear in addition to ones with file 
name for org-refile, but it has not happened. It was not clear at first 
that it is possible to start query with "/" and file name is added when 
TAB is pressed.


Is it expected that with cache enabled, command that causes cache update 
affects appearance of completion options to its sibling (org-refile and 
org-goto)?





Re: [tip for EXWM users] An alternative method for isolate trees

2021-03-02 Thread Julian M. Burgos
Hi Kyle,

You are right. When running emacs without my personal config things work as 
described in the manual.  I should have verified that first.

My best,

Julian

Kyle Meyer writes:

> Julian M. Burgos writes:
>
>> I have not noticed that org-tree-to-indirect-buffer
>> reuses the indirect buffer when you call it for a second time.
>> According to the manual, "with a C-u prefix, do not remove the
>> previously used indirect buffer", but that does not seem to work.
>> When you do Cu-Cc-Cx-b from a buffer that already has an indirect
>> buffer you get a "cannot modify an area being edited in a dedicated
>> buffer".  If you try it from a different buffer, the prefix is ignored
>> and the indirect buffer is assigned to the tree from the last buffer.
>
> Hmm, could you provide a reproducer for the problem?  Here's what I
> tried with the current master (afd75d05a), Emacs 27.1, and no custom
> configuration.
>
> --8<---cut here---start->8---
> * a
> a content
> * b
> b content
> --8<---cut here---end--->8---
>
>  - on "a", C-c C-x b  ;; org-tree-to-indirect-buffer
>Displays -a-1 buffer.
>
>  - move to "b", C-u C-c C-x b
>Displays -b-1 buffer, a-1 buffer still exists.


--
Julian Mariano Burgos, PhD
Hafrannsóknastofnun, rannsókna- og ráðgjafarstofnun hafs og vatna/
Marine and Freshwater Research Institute
Botnsjávarsviðs / Demersal Division
  Fornubúðir 5, IS-220 Hafnarfjörður, Iceland
www.hafogvatn.is
Sími/Telephone : +354-5752037
Netfang/Email: julian.bur...@hafogvatn.is