[PATCH] Org Capture Add Tags with org-toggle-tag

2022-02-02 Thread Kevin Foley
I have a capture template which utilizes %^g to prompt me for a tag to
add to a headline which already has a tag.  An example to demonstrate
is:

* TODO %? %^g :foo:

If I call this template and give it "bar" when prompted for a tag, it
results in (where | is the cursor position):

* TODO | :bar::foo:

And bar is recognized as a tag.

I've been able to resolve this with the attached patch.  However,
looking at the git history of that code it seems the intent might have
been to prevent some recursive resolution so I'm not sure if this breaks
that.

I've realized I could also attach the %^g to :foo: tag in the template
and things work as expected but if that's the expectation then I think
it's worth mentioning in the docstring for org-capture-templates.

Thanks,
Kevin
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 5195b785e..b27de40fe 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1753,9 +1753,7 @@ (defun org-capture-fill-template ( template initial annotation)
  'org-tags-history))
   ":")))
 		   (when (org-string-nw-p ins)
-			 (unless (eq (char-before) ?:) (insert ":"))
-			 (insert ins)
-			 (unless (eq (char-after) ?:) (insert ":"))
+			 (org-toggle-tag ins 'on)
 			 (when (org-at-heading-p) (org-align-tags)
 		((or "C" "L")
 		 (let ((insert-fun (if (equal key "C") #'insert


[PATCH] Add tests for org agenda bulk functions

2021-02-20 Thread Kevin Foley
>From 1f7bdcaa40ccb562c4a04bc1bd27517ca1e69bea Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Sat, 20 Feb 2021 13:42:44 -0500
Subject: [PATCH] test-org-agenda.el: Test bulk functions

* testing/lisp/test-org-agenda.el (org-test-agenda-with-agenda):
Create macro to setup agenda for tests.
(test-org-agenda/bulk): Test that bulk actions are applied to marked
items.
(test-org-agenda/bulk-custom): Test that custom bulk actions are
applied to marked items.
(test-org-agenda/bulk-custom-arg-func): Test that argument collection
function is properly called for custom bulk functions.
---
 testing/lisp/test-org-agenda.el | 68 +
 1 file changed, 68 insertions(+)

diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index 7c1bfb2be..22449a73b 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -42,6 +42,13 @@ (defun org-test-agenda--kill-all-agendas ()
   (mapc #'kill-buffer
 	(org-test-agenda--agenda-buffers)))
 
+(defmacro org-test-agenda-with-agenda (text  body)
+  (declare (indent 1))
+  `(org-test-with-temp-text-in-file ,text
+ (let ((org-agenda-files `(,buffer-file-name)))
+   ,@body
+   (org-test-agenda--kill-all-agendas
+
 
 ;; Test the Agenda
 
@@ -180,6 +187,67 @@ (ert-deftest test-org-agenda/diary-inclusion ()
 (should (search-forward "f0bcf0cd8bad93c1451bb6e1b2aaedef5cce7cbb" nil t))
 (org-test-agenda--kill-all-agendas)))
 
+;; agenda bulk actions
+
+(ert-deftest test-org-agenda/bulk ()
+  "Bulk actions are applied to marked items."
+  (org-test-agenda-with-agenda "* TODO a\n* TODO b"
+(org-todo-list)
+(org-agenda-bulk-mark-all)
+(cl-letf (((symbol-function 'read-char-exclusive)
+   (lambda () ?t))
+  ((symbol-function 'completing-read)
+   (lambda ( rest) "DONE")))
+  (org-agenda-bulk-action))
+(org-agenda-previous-item 99)
+(should (looking-at ".*DONE a"))
+(org-agenda-next-item 1)
+(should (looking-at ".*DONE b"
+
+(ert-deftest test-org-agenda/bulk-custom ()
+  "Custom bulk actions are applied to all marked items."
+  (org-test-agenda-with-agenda "* TODO a\n* TODO b"
+(org-todo-list)
+(org-agenda-bulk-mark-all)
+
+;; Mock read functions
+(let* ((f-call-cnt 0)
+   (org-agenda-bulk-custom-functions
+   `((?P ,(lambda () (setq f-call-cnt (1+ f-call-cnt)))
+  (cl-letf* (((symbol-function 'read-char-exclusive)
+  (lambda () ?P)))
+(org-agenda-bulk-action)
+(should (= f-call-cnt 2))
+
+(ert-deftest test-org-agenda/bulk-custom-arg-func ()
+  "Argument collection functions can be specified for custom bulk
+functions."
+  (org-test-agenda-with-agenda "* TODO a\n* TODO b"
+(org-todo-list)
+(org-agenda-bulk-mark-all)
+(let* ((f-called-cnt 0)
+   (arg-f-call-cnt 0)
+   (f-called-args nil)
+   (org-agenda-bulk-custom-functions
+`((?P
+   ;; Custom bulk function
+   ,(lambda ( args)
+  (message "test" args)
+  (setq f-called-cnt (1+ f-called-cnt)
+
+f-called-args args))
+   ;; Argument collection function
+   ,(lambda ()
+  (setq arg-f-call-cnt (1+ arg-f-call-cnt))
+  '(1 2 3))
+  (cl-letf (((symbol-function 'read-char-exclusive)
+ (lambda () ?P)))
+(org-agenda-bulk-action))
+  (should (= f-called-cnt 2))
+  (should (= arg-f-call-cnt 1))
+  (should (equal f-called-args '(1 2 3))
+
+
 
 (provide 'test-org-agenda)
 
-- 
2.28.0




Re: Assistance Writing Test for Org Agenda Custom Bulk Function

2021-02-18 Thread Kevin Foley
Kyle Meyer  writes:

> Unrelated note: there's a missing a space between the second "*" and
> "TODO".

Good catch, thank you.

> Perhaps you're not capturing the environment due to your quoting:
>
>   ;; -*- lexical-binding: t; -*-
>
>   (let ((x 0))
> '(t (lambda () x)))  ;; => (y (lambda nil x))
>   
>   (let ((x 0))
> (list t (lambda () x)))  ;; => (t (closure ((x . 0) t) nil x))
>
> So try something like
>
>   (org-agenda-bulk-custom-functions
>`((?P ,(lambda ( args)
> (message "test" args)
> (setq f-called-cnt (1+ f-called-cnt)
>   f-called-args args))
>  ,(lambda ()
> (setq arg-f-call-cnt (1+ arg-f-call-cnt))
> '(1 2 3)

This was exactly it, thank you.  I'll hopefully have this in a patch
shortly.

Kevin




Assistance Writing Test for Org Agenda Custom Bulk Function

2021-02-15 Thread Kevin Foley
I'm trying write a test for a recently merged patch[1].

The patch adds the ability for users to specify a function to collect
args to be passed to a custom bulk function.

I'm trying to mock the argument collecting function and the custom bulk
function and then test that the arguments returned from the former are
passed to the latter.  I'd also like to test the argument function is
only called once while the bulk function is called multiple times.

Here is an example of what I'm trying to do:

(org-test-with-temp-text-in-file
"* TODO a\n*TODO b"
  (let ((org-agenda-files `(,(buffer-file-name
(org-todo-list)
(org-agenda-bulk-mark-all)

;; Fails without these
;; (defvar f-called-cnt)
;; (defvar arg-f-call-cnt)
;; (defvar f-called-args)

(let ((f-called-cnt 0)
  (arg-f-call-cnt 0)
  (f-called-args nil))
  (cl-letf (((symbol-function 'read-char-exclusive)
 (lambda () ?P))
(org-agenda-bulk-custom-functions
 '((?P (lambda ( args)
 (message "test" args)
 (setq f-called-cnt (1+ f-called-cnt)
   f-called-args args))
   (lambda ()
 (setq arg-f-call-cnt (1+ arg-f-call-cnt))
 '(1 2 3))
(org-agenda-bulk-action)
(org-test-agenda--kill-all-agendas)

(should (= f-called-cnt 2))
(should (= arg-f-call-cnt 1))
(should (equal f-called-args '(1 2 3)))

However, this fails with the error void-variable unless I first define
the variables for storing the call counts/arguments.  I understand that
defvar makes the variables dynamically bound, however I'm struggling to
understand why that's needed here.  I've read the manual entries on
variable binding but I seem to be missing something.

Can someone help me understand what's going on here?  Also, is there a
better way to approach this?

[1] 
https://code.orgmode.org/bzg/org-mode/commit/885ee086dde4ec2a9e303ff101e55d55c4b2363f



Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt)

2021-02-15 Thread Kevin Foley
> Thanks again for the nice addition.
My pleasure, thanks for all of your feedback.

Also I took another look at adding a test around this, will hopefully
have another patch to submit for that.

Kevin



Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt)

2021-02-14 Thread Kevin Foley
Kyle Meyer  writes:
> Kevin Foley writes:
>
>> Side note I'm not sure your example would render properly regardless
>> since `my/bulk-action' and `my/args' aren't functions.
>
> I'm confused by this.  They were defined just above the text you
> quoted:

Sorry about that, I completely missed those.

> Aren't the pcase-let bindings missing a set of parentheses?

Hmm, you're right.  I swear I tested it and it was working so I'm not
sure if I accidentally dropped them or what.

I was hoping to add a test for this use case but it ended up seeming
like a rather large task with how much the function handles coupled with
my inexperience with ERT.

> However, I don't see using pcase-let here as an improvement.  Admittedly
> it's mostly subjective, but I think it's unhelpfully permissive for this
> use case:
>
>   (pcase-let ((`(,a ,b) (list 1 2 3 4)))
> (list a b))  ; => (1 2)
>
> Fwiw, here's a relevant emacs.devel thread:
> https://lists.gnu.org/archive/html/emacs-devel/2015-07/msg00103.html
> (message ID: )

I actually intended to be overly permissive in case additional options
are added in the future.  For example I was thinking it would be nice to
be able to assign a label to the custom action.

> My pcase-based suggestion, on top of your patch, is below.  If that
> looks okay to you, there's no need to resend; I can squash it in.

I'll defer to your pcase solution as I think my reasoning for using
pcase-let isn't particularly strong and I agree your suggestion is
cleaner.

Kevin Foley



Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt)

2021-02-13 Thread Kevin Foley
Kyle Meyer  writes:
> Please fill this line (fill-column in .dir-locals.el is set to 70)
> and...
>> [...]
> ... drop this unrelated space change.

Done and done.

> Reading this docstring in full, I felt it was a bit odd to repeat the
> bulk-cut entry from the initial example again, as it stays the same and
> isn't relevant.  So perhaps something like this would be clearer:
>
>   ... and returns them as a list.  For example, the first
>   entry in the above example could be extended as
>   
> (?R (set-category get-category))
>   
>   Now, `B R' will ...
>
> Or perhaps not.  I'm okay with it either way and will leave that up to
> you.

I agree, I've removed it.


> Please drop the new line before the closing quote.

Done.

> convention nit: It'd be good to reflow the type to not go beyond ~80
> columns.

Fixed.

>> +  :type '(alist :key-type character
>> +:value-type (list (function :tag "Bulk Custom Function")
>> +  (choice (const :tag "No Bulk Custom 
>> Argument Function" nil)
>> +  (function :tag "Bulk Custom 
>> Argument Function"
> This type looks like it's specifying a format that isn't supported by
> org-agenda-bulk-action:
> [...]
> I think it'd probably end up a bit cleaner if you go with (key fn
> [arg-fn])

I ended up moving to this structure and changing the pcase to a
pcase-let which I think makes things a bit cleaner, let me know your
thoughts.

>   (setq org-agenda-bulk-custom-functions
> '((?D my/bulk-action)
>   (?E (my/bulk-action))
>   (?F (my/bulk-action my/args
> However, customize doesn't render the above value properly

I believe I have the type correct for the new layout.  For example the
following renders correctly:

(setq org-agenda-bulk-custom-functions 
  '((?a ignore)
(?b ignore nil)
(?c ignore ignore)))

Side note I'm not sure your example would render properly regardless
since `my/bulk-action' and `my/args' aren't functions.

Cheers,
Kevin Foley

>From 3d5dc61c1565695e797936af1f2eb50cd5460c95 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Sat, 13 Feb 2021 12:04:38 -0500
Subject: [PATCH] org-agenda.el: Support argument collection for custom bulk
 functions

* lisp/org-agenda.el (org-agenda-bulk-custom-functions): Add
documentation about argument collection for custom bulk functions.
(org-agenda-bulk-action): Support function to collect arguments for
custom bulk functions.
* etc/ORG-NEWS (Option ~org-agenda-bulk-custom-functions~ now supports
collecting bulk arguments): Add entry to NEWS.
---
 etc/ORG-NEWS   |  7 +++
 lisp/org-agenda.el | 34 +++---
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5e5f1954d..d7de97e2c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -81,6 +81,13 @@ block. ~org-babel-latex-preamble~, ~org-babel-latex-begin-env~ and
 the user to specify the preamble and code that preceedes and proceeds
 the contents of the source block.
 
+*** Option ~org-agenda-bulk-custom-functions~ now supports collecting bulk arguments
+
+When specifying a custom agenda bulk option, you can now also specify
+a function which collects the arguments to be used with each call to
+the custom function.
+
+
 ** New features
 *** =ob-python= improvements to =:return= header argument 
 
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dedf7e5bb..42d127232 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2080,9 +2080,25 @@ (defcustom org-agenda-bulk-custom-functions nil
 
 With selected entries in an agenda buffer, `B R' will call
 the custom function `set-category' on the selected entries.
-Note that functions in this alist don't need to be quoted."
-  :type '(alist :key-type character :value-type (group function))
-  :version "24.1"
+Note that functions in this alist don't need to be quoted.
+
+You can also specify a function which collects arguments to be
+used for each call to your bulk custom function.  The argument
+collecting function will be run once and should return a list of
+arguments to pass to the bulk function.  For example:
+
+  \\='((?R set-category get-category))
+
+Now, `B R' will call the custom `get-category' which would prompt
+the user once for a category.  That category is then passed as an
+argument to `set-category' for each entry it's called against."
+  :type
+  '(alist :key-type character
+	  :value-type
+  (group (function :tag "Bulk Custom Function")
+		 (choice (function :tag "Bulk Custom Argument Function")
+		 (const :tag "No Bulk Custom Argument Function" nil
+  :package-version '(Org . "9.5")
   :group 'org-agenda)
 
 (defmacro org-agenda-with

Refile Targets Custom Function Support

2021-01-29 Thread Kevin Foley
I'd like to use an `org-ql' query in order to get eligible targets when
calling `org-refile'.

It doesn't seem `org-refile-targets' supports something like passing a
function that returns the desired targets.  Is it possible through some
other means?

If not, would a patch to `org-refile-get-targets' controlled by a new
type in `org-refile-targets' be welcome?  

Thanks,
Kevin Foley




Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt)

2021-01-27 Thread Kevin Foley
Kyle Meyer  writes:

Thanks for the review Kyle.

> nit: No ":" after "lisp/org-agenda.el".

Fixed.

> Drop either "about" or "for"?

Fixed.

> In addition to the NEWS entry that Ihor mentioned, it looks like an
> update to the manual is missing.

NEWS entry added.  With regard to the manual, the custom bulk function
option is only mentioned as a footnote.  I'm happy to add a more in
depth explanation, however I'm not sure where it should go, any
recommendations?

> s/it's/its/

Fixed.

> Should this :type be updated?

Updated.  I went with list with and optional second element for the
argument collection function (I also updated my patch to handle a nil
second argument).

I think it makes sense to encourage use of the list even when not using
an argument collection function but let me know if you think a choice
between function and list would be better.

> Please update this version, or rather drop :version and add
>   :package-version '(Org . "9.5")

Updated.


Thanks,
Kevin

>From 1d09a90abcb4136a3cf7562870f7eda831f163d3 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Thu, 21 Jan 2021 08:48:52 -0500
Subject: [PATCH] org-agenda.el: Support argument collection for custom bulk
 functions

* lisp/org-agenda.el (org-agenda-bulk-custom-functions): Add
documentation about argument collection for custom bulk functions.
(org-agenda-bulk-action): Support function to collect arguments for
custom bulk functions.
* etc/ORG-NEWS (Option ~org-agenda-bulk-custom-functions~ now supports
collecting bulk arguments): Add entry to NEWS.
---
 etc/ORG-NEWS   |  7 ++-
 lisp/org-agenda.el | 29 +
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 5e5f1954d..4958d2b2e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -81,8 +81,13 @@ block. ~org-babel-latex-preamble~, ~org-babel-latex-begin-env~ and
 the user to specify the preamble and code that preceedes and proceeds
 the contents of the source block.
 
+*** Option ~org-agenda-bulk-custom-functions~ now supports collecting bulk arguments
+
+When specifying a custom agenda bulk option, you can now also specify a function which collects the arguments to be used with each call to the custom function.
+
+
 ** New features
-*** =ob-python= improvements to =:return= header argument 
+*** =ob-python= improvements to =:return= header argument
 
 The =:return= header argument in =ob-python= now works for session
 blocks as well as non-session blocks.  Also, it now works with the
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dedf7e5bb..c5c1b54ba 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2080,9 +2080,25 @@ (defcustom org-agenda-bulk-custom-functions nil
 
 With selected entries in an agenda buffer, `B R' will call
 the custom function `set-category' on the selected entries.
-Note that functions in this alist don't need to be quoted."
-  :type '(alist :key-type character :value-type (group function))
-  :version "24.1"
+Note that functions in this alist don't need to be quoted.
+
+If the custom function accepts arguments which you'd like to
+collect once from the user to be used for each call, you can pass
+a list with the bulk function, and the function which collects
+its arguments and returns them as a list.  For example:
+
+  \\='((?R (set-category get-category))
+(?C bulk-cut))
+
+Now, `B R' will call the custom `get-category' which would prompt
+the user once for a category.  That category is then passed as an
+argument to `set-category' for each entry it's called against.
+"
+  :type '(alist :key-type character
+:value-type (list (function :tag "Bulk Custom Function")
+  (choice (const :tag "No Bulk Custom Argument Function" nil)
+  (function :tag "Bulk Custom Argument Function"
+  :package-version '(Org . "9.5")
   :group 'org-agenda)
 
 (defmacro org-agenda-with-point-at-orig-entry (string  body)
@@ -10487,7 +10503,12 @@ (defun org-agenda-bulk-action ( arg)
 
 	(action
 	 (pcase (assoc action org-agenda-bulk-custom-functions)
-	   (`(,_ ,f) (setq cmd f) (setq redo-at-end t))
+	   (`(,_ ,f)
+(when (listp f)
+  (let ((args (when (nth 1 f) (funcall (nth 1 f
+(func (nth 0 f)))
+(setq f (apply #'apply-partially func args
+(setq cmd f) (setq redo-at-end t))
 	   (_ (user-error "Invalid bulk action: %c" action)
 
   ;; Sort the markers, to make sure that parents are handled
-- 
2.28.0



Re: [PATCH] Org Agenda Support Argument Collection for Custom Bulk Functions (was: Custom Bulk Functions With Prompt)

2021-01-21 Thread Kevin Foley
Attached patch should allow user to specify a function to collect
arguments when calling a custom bulk function such that those arguments
are only collected once and used for each entry.

Kevin Foley

>From dfab64f738f227691d84a2fdec5bba2cf4f1e3b0 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Thu, 21 Jan 2021 08:48:52 -0500
Subject: [PATCH] org-agenda.el: Support argument collection for custom bulk
 functions

* lisp/org-agenda.el: (org-agenda-bulk-custom-functions): Add
documentation about for collection arguments for custom bulk functions.
(org-agenda-bulk-action): Support function to collect arguments for
custom bulk functions.
---
 lisp/org-agenda.el | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dedf7e5bb..deadacc1e 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -2080,7 +2080,20 @@ (defcustom org-agenda-bulk-custom-functions nil
 
 With selected entries in an agenda buffer, `B R' will call
 the custom function `set-category' on the selected entries.
-Note that functions in this alist don't need to be quoted."
+Note that functions in this alist don't need to be quoted.
+
+If the custom function accepts arguments which you'd like to
+collect once from the user to be used for each call, you can pass
+a list with the bulk function, and the function which collects
+it's arguments and returns them as a list.  For example:
+
+  \\='((?R (set-category get-category))
+(?C bulk-cut))
+
+Now, `B R' will call the custom `get-category' which would prompt
+the user once for a category.  That category is then passed as an
+argument to `set-category' for each entry it's called against.
+"
   :type '(alist :key-type character :value-type (group function))
   :version "24.1"
   :group 'org-agenda)
@@ -10487,7 +10500,12 @@ (defun org-agenda-bulk-action ( arg)
 
 	(action
 	 (pcase (assoc action org-agenda-bulk-custom-functions)
-	   (`(,_ ,f) (setq cmd f) (setq redo-at-end t))
+	   (`(,_ ,f)
+(when (listp f)
+  (let ((args (funcall (nth 1 f)))
+(func (nth 0 f)))
+(setq f (apply #'apply-partially func args
+(setq cmd f) (setq redo-at-end t))
 	   (_ (user-error "Invalid bulk action: %c" action)
 
   ;; Sort the markers, to make sure that parents are handled
-- 
2.28.0



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: Custom Bulk Functions With Prompt

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

> Note that attachment in the previous email appears to be empty. Can you
> resend? I will take a look then.

My mistake, populated file is attached. Thanks.

Kevin

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index dedf7e5bb..1df99ec79 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -10487,7 +10487,12 @@ (defun org-agenda-bulk-action ( arg)
 
 	(action
 	 (pcase (assoc action org-agenda-bulk-custom-functions)
-	   (`(,_ ,f) (setq cmd f) (setq redo-at-end t))
+	   (`(,_ ,f)
+(when (listp f)
+  (let ((args (funcall (nth 1 f)))
+(func (nth 0 f)))
+(setq f (apply #'apply-partially func args
+(setq cmd f) (setq redo-at-end t))
 	   (_ (user-error "Invalid bulk action: %c" action)
 
   ;; Sort the markers, to make sure that parents are handled


Re: Custom Bulk Functions With Prompt

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

> Instead of advice, you can also provide a simple patch implementing the
> described functionality in org-agenda-bulk-action. I do support adding
> this functionality to org.

I took a look this morning and came up with the attached patch.
Essentially if the custom function is a list then the first element is
the bulk function and the second is the argument function.

If that looks reasonable I can add some documentation and submit a
proper patch.

Kevin Foley


Custom Bulk Functions With Prompt

2021-01-16 Thread Kevin Foley
I'd like to setup a custom bulk function using
`org-agenda-bulk-custom-functions', however I'd like to receive one
prompt when I select the action and then have the action performed on
every entry without being prompted again.

For example the bulk tag function lets the user specify a tag once, then
applies that to every entry.  As far as I can tell from looking through
the source code, there's no way to replicate this via a custom function.

Is there something I'm missing that would allow me to do this?  If not,
any suggestions on how support for it could be implemented?  I'd be
happy to submit a patch but I'm not sure of the best way to approach it.

Kevin Foley



Re: [PATCH] Org Refile Document RFLOC (was: Org Refile RFLOC and Struct Type)

2020-10-18 Thread Kevin Foley
Kyle Meyer  writes:

> I imagine tastes vary on whether using cl-defstruct here is an overkill.
> (To my eyes, it is.)  More importantly, though, I think changing it now
> means we'd also need a compatibility layer, which doesn't seem worth the
> trouble.

I tried implementing it and realized:

1. It have issues with backwards compatibility (like you mentioned).
There are some workarounds but they add complexity 2. It can make other
things complicated. For example using `assoc' to look things up no longer
works so a lot needs to be updated.

Personally I think it's worth it as it makes things much clearer but I
understand why others may not feel that way and it's not something I
feel strongly enough about to push for.

> Thanks for noticing and for working on a patch.

My pleasure, I've attached a patch to this email.  I put something
together but I wasn't sure how it should be styled/formatted so if
anyone has any suggestions I'd be happy to update it.

Kevin

>From 87af8fc4a08c8b4b2c9c508d0bad0565c0d10429 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Sun, 18 Oct 2020 21:30:52 -0400
Subject: [PATCH] org-refile.el (org-refile) Add description of RFLOC to
 docstring

---
 lisp/org-refile.el | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 7eb0a9643..4d56f2e9a 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -414,7 +414,16 @@ (defun org-refile ( arg default-buffer rfloc msg)
 Beware that keeping refiled entries may result in duplicated ID
 properties.
 
-RFLOC can be a refile location obtained in a different way.
+RFLOC can be a refile location obtained in a different way.  It
+should be a list with the following 4 elements:
+
+1. Name - an identifier for the refile location, typically the
+headline text.
+2. File - the file the refile location is in
+3. nil - Used for generating refile location candidates, not
+needed when passing RFLOC
+4. Position-  the position in the specified file of the
+headline to refile under
 
 MSG is a string to replace \"Refile\" in the default prompt with
 another verb.  E.g. `org-copy' sets this parameter to \"Copy\".
-- 
2.28.0



Org Refile RFLOC and Struct Type

2020-10-13 Thread Kevin Foley
I was recently working with `org-refile` and wanted to use a custom
target.  There is the `rfloc` argument which is documented as:

> RFLOC can be a refile location obtained in a different way.

There's no documentation as to how `rfloc` should be structured.  To
figure that out one has to read through the code which is made even more
difficult by the fact that the same argument is called `refloc` in
`org-refile--get-location`.

I plan to submit a patch to address this, however I wanted feedback on
whether using a struct type (cl-defstruct) could be an improvement
here before trying to implement it.

It seems using a defined structure would make both the documentation and
code more clear, however I rarely (if ever) have seen structures used in
the elisp code I'm familiar with.  Is there a downside to using struct
types that would make it a poor choice in this case?

Kevin



[PATCH] test-ob-tangle.el: Fix dirty repo state caused by testing

2020-05-26 Thread Kevin Foley

The attached patch kills the buffer of the file modified
during testing to prevent leaving the repo in a dirty state.

Thanks to Kyle for seeing this and providing guidance on how to
address.

Thanks,
Kevin

>From 46dd1cf3c34a372612e4a67a79afd84ca3317500 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Tue, 26 May 2020 20:42:54 -0400
Subject: [PATCH] test-ob-tangle.el: Fix dirty repo state caused by testing

* testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
Kill modified buffer after test.

Another test is causing the modifications to be saved which leaves the
repo in a dirty state after testing.
---
 testing/lisp/test-ob-tangle.el | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index ed75e6ca4..bd2d99ca2 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -384,12 +384,14 @@ (ert-deftest ob-tangle/commented-src-blocks ()

 (ert-deftest ob-tangle/detangle-false-positive ()
   "Test handling of false positive link during detangle."
-  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
-(org-babel-detangle)
-(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
-(org-babel-next-src-block)
-(should (equal (string-trim (org-element-property :value (org-element-at-point)))
-		   ";; detangle changes")
+  (unwind-protect
+  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
+	(org-babel-detangle)
+	(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
+	  (org-babel-next-src-block)
+	  (should (equal (string-trim (org-element-property :value (org-element-at-point)))
+			 ";; detangle changes"
+(kill-buffer "babel.org")))

 (provide 'test-ob-tangle)

--
2.19.0


Re: [PATCH] Fix `org-babel-detangle' handling of false positives

2020-05-24 Thread Kevin Foley
Kyle Meyer  writes:

> Kevin, could you look into updating the test to avoid changing the repo
> state?

Sorry about that.  Do you have any suggestions on how to avoid changing
the state or any examples of similar tests?

I tried the following to replace the file with it's original contents
but it doesn't seem to be working as I intend.  I also worry it's a
convoluted approach and there may be a simpler way.

diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index ed75e6ca4..a91bd3446 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -384,12 +384,19 @@ (ert-deftest ob-tangle/commented-src-blocks ()

 (ert-deftest ob-tangle/detangle-false-positive ()
   "Test handling of false positive link during detangle."
-  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
-(org-babel-detangle)
-(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
-(org-babel-next-src-block)
-(should (equal (string-trim (org-element-property :value 
(org-element-at-point)))
-  ";; detangle changes")
+  (let* ((babel-org-file (expand-file-name "babel.org" org-test-example-dir))
+(orig-file-buffer
+ (get-buffer-create " bable-org")))
+(with-current-buffer orig-file-buffer (insert-file-contents 
babel-org-file))
+(org-test-in-example-file (expand-file-name "babel.el" 
org-test-example-dir)
+  (org-babel-detangle)
+  (org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
+   (org-babel-next-src-block)
+   (should (equal (string-trim (org-element-property :value 
(org-element-at-point)))
+  ";; detangle changes"
+(with-current-buffer orig-file-buffer
+  (kill-buffer (get-file-buffer babel-org-file))
+  (write-region (point-min) (point-max) babel-org-file

 (provide 'test-ob-tangle)


Thanks,
Kevin



Re: [PATCH] Fix `org-babel-detangle' handling of false positives

2020-05-24 Thread Kevin Foley
Hi Bastien,

Bastien  writes:

> I tried to apply your patch but I was not able to apply it, perhaps
> just a problem with extracting it from your email.
>
> Can you send an (perhaps updated) version as an attachment?

What issue did you have?

I was able to download and apply the original patch to the latest commit
on master (701c7bed) without any issues/conflicts using =git am --
=.  I'm new to patch based development so I may be
missing something.

I've tried recreating the patch and attaching to this message, hopefully
that resolves it.  I've also attached it as "text/x-patch" instead of
"text/plain" which I used last time, I'm not sure if that causes issues
or if one is preferred.

>From eae83992e0c671d0162ba60f567629138ecc0074 Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Tue, 28 Jan 2020 17:51:29 -0500
Subject: [PATCH] Fix `org-babel-detangle' handling of false positives

* lisp/ob-tangle.el (org-babel-detangle): Handle false positive
matches of `org-link-bracket-re'

* testing/examples/babel.el: New file for babel detangle false
positive test

* testing/examples/babel.org (detangle): Add detangle/false positive
example

* testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
Add test for detangle false positive
---
 lisp/ob-tangle.el  | 18 ++
 testing/examples/babel.el  |  5 +
 testing/examples/babel.org | 13 +
 testing/lisp/test-ob-tangle.el | 11 +++
 4 files changed, 39 insertions(+), 8 deletions(-)
 create mode 100644 testing/examples/babel.el

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 8fd407478..4fe444532 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -516,14 +516,16 @@ (defun org-babel-detangle ( source-code-file)
 (goto-char (point-min))
 (let ((counter 0) new-body end)
   (while (re-search-forward org-link-bracket-re nil t)
-(when (re-search-forward
-	   (concat " " (regexp-quote (match-string 2)) " ends here"))
-  (setq end (match-end 0))
-  (forward-line -1)
-  (save-excursion
-	(when (setq new-body (org-babel-tangle-jump-to-org))
-	  (org-babel-update-block-body new-body)))
-  (setq counter (+ 1 counter)))
+(if (and (match-string 2)
+		 (re-search-forward
+		  (concat " " (regexp-quote (match-string 2)) " ends here") nil t))
+	(progn (setq end (match-end 0))
+		   (forward-line -1)
+		   (save-excursion
+		 (when (setq new-body (org-babel-tangle-jump-to-org))
+		   (org-babel-update-block-body new-body)))
+		   (setq counter (+ 1 counter)))
+	  (setq end (point)))
 (goto-char end))
   (prog1 counter (message "Detangled %d code blocks" counter)
 
diff --git a/testing/examples/babel.el b/testing/examples/babel.el
new file mode 100644
index 0..a7bb0ccf5
--- /dev/null
+++ b/testing/examples/babel.el
@@ -0,0 +1,5 @@
+(string-match-p "^#[[:digit:]]+$" "#123")
+
+;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]]
+;; detangle changes
+;; linked content to detangle:1 ends here
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index c889d5d92..b0942800a 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -488,3 +488,16 @@ nil
 #+BEGIN_SRC emacs-lisp :output-dir xxx :file foo.bar
 nil
 #+END_SRC
+* detangle
+** false positive
+The =[[= causes a false positive which ~org-babel-detangle~ should handle properly
+#+begin_src emacs-lisp :tangle yes
+(string-match-p "^#[[:digit:]]+$" "#123")
+#+end_src
+** linked content to detangle
+:PROPERTIES:
+:ID:   73115FB0-6565-442B-BB95-50195A499EF4
+:END:
+#+begin_src emacs-lisp :tangle yes :comments link
+  ;; detangle
+#+end_src
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index 301f7aff7..ed75e6ca4 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(require 'subr-x)
+
 ;; TODO
 ;; (ert-deftest ob-tangle/noweb-on-tangle ()
 ;;   "Noweb header arguments tangle correctly.
@@ -380,6 +382,15 @@ (ert-deftest ob-tangle/commented-src-blocks ()
 		(org-split-string (buffer-string
 	  (delete-file file))
 
+(ert-deftest ob-tangle/detangle-false-positive ()
+  "Test handling of false positive link during detangle."
+  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
+(org-babel-detangle)
+(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
+(org-babel-next-src-block)
+(should (equal (string-trim (org-element-property :value (org-element-at-point)))
+		   ";; detangle changes")
+
 (provide 'test-ob-tangle)
 
 ;;; test-ob-tangle.el ends here
-- 
2.19.0


Thanks,
Kevin


Re: [PATCH] Fix `org-babel-detangle' handling of false positives

2020-05-22 Thread Kevin Foley


Hi,

I've completed the copyright assignment so should be good to go with
this.

Haven't had a chance to see if any conflicts have come up in the
meantime but will try to take a look today.

Kevin



Re: [PATCH] Fix `org-babel-detangle' handling of false positives

2020-02-09 Thread Kevin Foley
Hi Bastien,

Thank you for the feedback!  I'm working with my employer regarding
copyright assignment and should have that sorted out shortly.  I'll
submit the proposed changes once that's taken care.

Kevin

Bastien  writes:

> Hi Kevin,
>
> this looks good.  The patch is significant enough that we need you to
> sign the FSF copyright assignment papers.  Here is the form:
>
> https://code.orgmode.org/bzg/org-mode/raw/master/request-assign-future.txt
>
> Once you're done with this, we can push your commit.
>
> Should you contribute more, we can give you push access.
>
> Some comments below:
>
> Foley  writes:
>
>> This patch fixes the way `org-babel-detangle' handles false positive
>> matches for links.  Without the patch it tries to use match data that
>> may not be present in a false positive.  I've also included a regression
>> test.
>>
>> This is my first contribution to Org Mode or Emacs and my first patch
>> by mailing list so please let me know if I've overlooked anything.
>>
>> Also note I have not assigned copyright to FSF at this time, however I
>> believe this change should be small enough to not require it.
>>
>> Kevin Foley
>>
>> From 82e2d108536101c5a5ff9f8a0009051e5a308a3a Mon Sep 17 00:00:00 2001
>> From: "Kevin J. Foley" 
>> Date: Tue, 28 Jan 2020 17:51:29 -0500
>> Subject: [PATCH] Fix `org-babel-detangle' handling of false positives
>>
>> * lisp/ob-tangle.el (org-babel-detangle): Handle false positive
>> matches of `org-link-bracket-re'
>   ^
>   There should be a "." at the end of
>   sentences in changelog entries.
>
>> * testing/examples/babel.el: New file for babel detangle false
>> positive test
>^
>Same here.
>
>> * testing/examples/babel.org (detangle): Add detangle/false positive
>> example
>  ^
>  And here.
>
>> * testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
>> Add test for detangle false positive
>   ^ And here.
>   
>> TINYCHANGE
>
> Well, there are more than 15 lines of changes.  Signing the FSF papers
> will allow you to submit more changes later.
>
> Thanks!
>
> -- 
>  Bastien



[PATCH] Fix `org-babel-detangle' handling of false positives

2020-01-29 Thread Kevin Foley
This patch fixes the way `org-babel-detangle' handles false positive
matches for links.  Without the patch it tries to use match data that
may not be present in a false positive.  I've also included a regression
test.

This is my first contribution to Org Mode or Emacs and my first patch
by mailing list so please let me know if I've overlooked anything.

Also note I have not assigned copyright to FSF at this time, however I
believe this change should be small enough to not require it.

Kevin Foley

>From 82e2d108536101c5a5ff9f8a0009051e5a308a3a Mon Sep 17 00:00:00 2001
From: "Kevin J. Foley" 
Date: Tue, 28 Jan 2020 17:51:29 -0500
Subject: [PATCH] Fix `org-babel-detangle' handling of false positives

* lisp/ob-tangle.el (org-babel-detangle): Handle false positive
matches of `org-link-bracket-re'

* testing/examples/babel.el: New file for babel detangle false
positive test

* testing/examples/babel.org (detangle): Add detangle/false positive
example

* testing/lisp/test-ob-tangle.el (ob-tangle/detangle-false-positive):
Add test for detangle false positive

TINYCHANGE
---
 lisp/ob-tangle.el  | 18 ++
 testing/examples/babel.el  |  5 +
 testing/examples/babel.org | 13 +
 testing/lisp/test-ob-tangle.el | 11 +++
 4 files changed, 39 insertions(+), 8 deletions(-)
 create mode 100644 testing/examples/babel.el

diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 946039869..4dac0f786 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -513,14 +513,16 @@ (defun org-babel-detangle ( source-code-file)
 (goto-char (point-min))
 (let ((counter 0) new-body end)
   (while (re-search-forward org-link-bracket-re nil t)
-(when (re-search-forward
-  (concat " " (regexp-quote (match-string 2)) " ends here"))
-  (setq end (match-end 0))
-  (forward-line -1)
-  (save-excursion
-   (when (setq new-body (org-babel-tangle-jump-to-org))
- (org-babel-update-block-body new-body)))
-  (setq counter (+ 1 counter)))
+(if (and (match-string 2)
+(re-search-forward
+ (concat " " (regexp-quote (match-string 2)) " ends here") nil 
t))
+   (progn (setq end (match-end 0))
+  (forward-line -1)
+  (save-excursion
+(when (setq new-body (org-babel-tangle-jump-to-org))
+  (org-babel-update-block-body new-body)))
+  (setq counter (+ 1 counter)))
+ (setq end (point)))
 (goto-char end))
   (prog1 counter (message "Detangled %d code blocks" counter)

diff --git a/testing/examples/babel.el b/testing/examples/babel.el
new file mode 100644
index 0..a7bb0ccf5
--- /dev/null
+++ b/testing/examples/babel.el
@@ -0,0 +1,5 @@
+(string-match-p "^#[[:digit:]]+$" "#123")
+
+;; [[id:73115FB0-6565-442B-BB95-50195A499EF4][detangle:1]]
+;; detangle changes
+;; linked content to detangle:1 ends here
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index c889d5d92..b0942800a 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -488,3 +488,16 @@ nil
 #+BEGIN_SRC emacs-lisp :output-dir xxx :file foo.bar
 nil
 #+END_SRC
+* detangle
+** false positive
+The =[[= causes a false positive which ~org-babel-detangle~ should handle 
properly
+#+begin_src emacs-lisp :tangle yes
+(string-match-p "^#[[:digit:]]+$" "#123")
+#+end_src
+** linked content to detangle
+:PROPERTIES:
+:ID:   73115FB0-6565-442B-BB95-50195A499EF4
+:END:
+#+begin_src emacs-lisp :tangle yes :comments link
+  ;; detangle
+#+end_src
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index 301f7aff7..ed75e6ca4 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -25,6 +25,8 @@
 
 ;;; Code:

+(require 'subr-x)
+
 ;; TODO
 ;; (ert-deftest ob-tangle/noweb-on-tangle ()
 ;;   "Noweb header arguments tangle correctly.
@@ -380,6 +382,15 @@ (ert-deftest ob-tangle/commented-src-blocks ()
(org-split-string (buffer-string
  (delete-file file))

+(ert-deftest ob-tangle/detangle-false-positive ()
+  "Test handling of false positive link during detangle."
+  (org-test-in-example-file (expand-file-name "babel.el" org-test-example-dir)
+(org-babel-detangle)
+(org-test-at-id "73115FB0-6565-442B-BB95-50195A499EF4"
+(org-babel-next-src-block)
+(should (equal (string-trim (org-element-property :value 
(org-element-at-point)))
+  ";; detangle changes")
+
 (provide 'test-ob-tangle)

 ;;; test-ob-tangle.el ends here
--
2.19.0


Re: [O] Bug: Removing and adding deadline bug in org agenda [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.1/lisp/org/)]

2018-09-18 Thread Kevin Foley
My mistake, I misread, thanks for the correction Robert.  FWIW I also am
unable to reproduce on 9.1.14

I would still suggest using C-c C-d with . as it seems like a simpler
workflow.

On Tue, Sep 18, 2018 at 10:32 AM Robert Pluim  wrote:

> Kevin Foley  writes:
>
> > The issue is once you use C-u C-c C-d to remove the deadline with your
> > point on the same line as the deadline, that line is removed and the
> point
> > stays in the same place.  That means point is now on Task 2 so calling
> > `org-deadline' there will apply to Task 2.
> >
>
> I believe the C-u C-c C-d is being done from the agenda buffer, not
> the org buffer, so the agenda should be able to keep track of the task
> location.
>
> Having said that, Iʼve not been able to reproduce this with Org 9.1.14
>
> Robert
>


-- 
Thanks,
Kevin Foley


Re: [O] Bug: Removing and adding deadline bug in org agenda [9.1.9 (release_9.1.9-65-g5e4542 @ /usr/share/emacs/26.1/lisp/org/)]

2018-09-18 Thread Kevin Foley
The issue is once you use C-u C-c C-d to remove the deadline with your
point on the same line as the deadline, that line is removed and the point
stays in the same place.  That means point is now on Task 2 so calling
`org-deadline' there will apply to Task 2.

I think the easiest solution is to just change the old deadline using C-c
C-d.  From the prompt you can just type . to change the date to today.
This seems easier than your current workflow and you won't have the same
issue.

See this page for more details on the date/time prompt, it's very versatile
- https://orgmode.org/manual/The-date_002ftime-prompt.html

On Tue, Sep 18, 2018 at 9:26 AM Benson Chu  wrote:

>
>
> Remember to cover the basics, that is, what you expected to happen and
> what in fact did happen. You don't know how to make a good report? See
>
> https://orgmode.org/manual/Feedback.html#Feedback
>
> Your bug report will be posted to the Org mailing list.
> 
>
> I have a problem in org agenda. I have been able to reproduce this bug
> in a simple environment. This is an example org file:
>
> * TODO Task 1
> 
> * TODO Task 2
>
> When I open org agenda, and I realize the deadline is far into the
> past, I want to move the deadline to today. So, the easiest thing I can
> think to do is C-u C-c C-d to remove the deadline, and then C-c C-d to
> add the deadline again to make it today. However, when I do this, the
> new deadline gets added to the task below, so I end up with something
> like this:
>
> * TODO Task 1
> * TODO Task 2
> 
>
> Is this the intended behavior? I think that org agenda expects the
> deadline location to remain the same, but instead it gets removed, and
> accidentally adds it to the next task, which is very annoying. A few
> tasks of mine have disappeared into my large agenda file, and I've had
> to go back digging through to re-find and deadline them because of
> this. Are there any workarounds? Thanks!
>
> Emacs : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
> of 2018-07-05
> Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @
> /usr/share/emacs/26.1/lisp/org/)
>
> current state:
> ==
> (setq
> org-src-mode-hook '(org-src-babel-configure-edit-buffer
> org-src-mode-configure-edit-buffer)
> org-after-todo-state-change-hook '(org-clock-out-if-current)
> org-metadown-hook '(org-babel-pop-to-session-maybe)
> org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
> org-agenda-files '("/home///org/test/test-bug.org
> ")
> org-mode-hook '(#[0 "\300\301\302\303\304$\207"
> [add-hook change-major-mode-hook org-show-block-all append local] 5]
> #[0 "\300\301\302\303\304$\207"
> [add-hook change-major-mode-hook org-babel-show-result-all append local] 5]
> org-babel-result-hide-spec org-babel-hide-all-hashes)
> org-archive-hook '(org-attach-archive-delete-maybe)
> org-confirm-elisp-link-function 'yes-or-no-p
> org-agenda-before-write-hook '(org-agenda-add-entry-text)
> org-metaup-hook '(org-babel-load-in-session-maybe)
> org-bibtex-headline-format-function #[257 "\300.\236A\207" [:title] 3
> "\n\n(fn ENTRY)"]
> org-babel-pre-tangle-hook '(save-buffer)
> org-tab-first-hook '(org-babel-hide-result-toggle-maybe
> org-babel-header-arg-expand)
> org-occur-hook '(org-first-headline-recenter)
> org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
> org-cycle-show-empty-lines
> org-optimize-window-after-visibility-change)
> org-speed-command-hook '(org-speed-command-activate
> org-babel-speed-command-activate)
> org-confirm-shell-link-function 'yes-or-no-p
> org-link-parameters '(("id" :follow org-id-open)
> ("rmail" :follow org-rmail-open :store org-rmail-store-link)
> ("mhe" :follow org-mhe-open :store org-mhe-store-link)
> ("irc" :follow org-irc-visit :store org-irc-store-link)
> ("info" :follow org-info-open :export org-info-export :store
> org-info-store-link)
> ("gnus" :follow org-gnus-open :store org-gnus-store-link)
> ("docview" :follow org-docview-open :export org-docview-export :store
> org-docview-store-link)
> ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
> ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete
> org-bbdb-complete-link :store org-bbdb-store-link)
> ("w3m" :store org-w3m-store-link) ("file+sys") ("file+emacs")
> ("doi" :follow org--open-doi-link) ("elisp" :follow org--open-elisp-link)
> ("file" :complete org-file-complete-link)
> ("ftp" :follow (lambda (path) (browse-url (concat "ftp:" path
> ("help" :follow org--open-help-link)
> ("http" :follow (lambda (path) (browse-url (concat "http:" path
> ("https" :follow (lambda (path) (browse-url (concat "https:" path
> ("mailto" :follow (lambda (path) (browse-url (concat "mailto:; path
> ("news" :follow (lambda (path) (browse-url (concat "news:; path
> ("shell" :follow org--open-shell-link))
> )
>
>
>

-- 
Thanks,
Kevin Foley


Re: [O] including the | character in a table

2018-07-25 Thread Kevin Foley
No problem, I actually just ran into the need to do this yesterday so your
question was very timely.

Kevin


Re: [O] including the | character in a table

2018-07-25 Thread Kevin Foley
You can use \vert to insert pipes in exported tables.


Kevin


On Wed, Jul 25, 2018, 6:21 AM Michel Schinz  wrote:

> Hello,
>
> On Wed, Jul 25, 2018, at 11:22, Alan Schmitt wrote:
> > I'm writing a cheat sheet for a programming language, and I'm having
> > trouble with operators that use |. For instance:
> >
> > | match expr with   | pattern matching |
> > | | pattern -> expr | action   |
> >
> > How can I escape the |? I tried putting a \ before but it does not work.
>
> I've used macros in the past for such a case. Quite heavyweight, but I
> didn't find anything better. Here is an example (which you could augment if
> you wanted to export to LaTeX too):
>
> #+MACRO: I @@html:@@
>
> | match expr with| pattern matching |
> | {{{I}}}pattern -> expr | action   |
>
> Michel.
>
>


Re: [O] Babel Edit Code Whole Session Context

2018-06-24 Thread Kevin Foley
Hi Grant,

> I hear you and think I understand what you say. I also know it can be
> irritating when
> somebody answers a slightly different question question you asked. If
> you humor me,
> I'm about to do that.

No problem, I appreciate all discussion on the matter.

> I don't know how to do what you ask. However, I have something to do
> that I would be
> pretty happy.

> 1. Set the default headers args to noweb :tangle
> 2. Develop blocks normally, without Company.
> 3. When I am ready to work on the whole codebase with company, tangle
> to a file.
> 4. Go to that file. Leverage Company and make changes. When you are
> done detangle.
> 5. Iterate

I'm thinking of trying to implement something similar.  My solution would
be to place all code from blocks of the same session into the edit buffer
and then narrow to only the section from the current code block.  Then all
features should work seamlessly.  I'm not quite sure the best approach to
do this but I'm going to start poking around in the source code to see if
it's feasible.

If anyone has a solution that's already available or any feedback on my
proposed approach I'd greatly appreciate it.

-- 
Thanks,
Kevin Foley


[O] Babel Edit Code Whole Session Context

2018-06-24 Thread Kevin Foley
Is there anyway to edit a source code block with the context of all other
source code blocks in the same session?  Specifically when working with
Python I'd like features like company to be able to use the rest of the
code in the session.

For example consider the following org file:

#+begin_src python :tangle yes :session my_session
  var = 'variable'

  var_upper = var.
#+end_src

#+begin_src python :tangle yes :session my_session
  var_lower = var.
#+end_src

If I call `org-edit-src-code` on the first block and move the point to
after the dot in "var." and call `elpy-company-backend` I get suggestions
of all methods associated with strings in Python.  However if I do the same
in the second code block I get the message "No completion found".

Is there any solution to this issue?

-- 
Thanks,
Kevin Foley


Re: [O] [POLL] Should Org tempo be enabled by default? (expand templates thru e.g. "<s[TAB]")

2018-04-30 Thread Kevin Foley
I should add that one issue with org-tempo is it doesn't seem to be
backwards compatible with old templates.  For example packages such as
ob-sql-mode and org-reveal have easy templates based on the old format such
as :

(add-to-list 'org-structure-template-alist
  `(,org-babel-sql-mode-template-selector
"#+BEGIN_SRC sql-mode ?\n\n#+END_SRC"
"#+BEGIN_SRC sql-mode ?\n\n#+END_SRC"))

https://github.com/nikclayton/ob-sql-mode/blob/8d36d312bec4a742bec8890373948a888cac18de/ob-sql-mode.el#L187

This causes the cryptic error "File mode specification error: (error Format
specifier doesn’t match argument type)" when trying to load org-mode which
took me ages to figure out and could potentially turn someone new to
org-mode/emacs off forever.

I think this would be a good reason to not enable org-tempo at least for
the time being until either it can handle templates in the old format, or
produces a less cryptic error for users.

Regards,
Kevin


Re: [O] [POLL] Should Org tempo be enabled by default? (expand templates thru e.g. "<s[TAB]")

2018-04-30 Thread Kevin Foley
Bastien  writes:

> Here is what the experience can look like:
>
> - Upgrading Emacs or Org (hurray!!)
> - Trying to hit  - Thinking your stupid

[...]

I have to admit that Bastien's list describes my experience almost
perfectly.  It look me a long time to figure out something that in the end
seemed very simple.  At the time I wasn't familiar with the NEWS file and
it didn't come up in any of my online searches.  It also didn't help that
site still documented the old behavior (and apparently still does
https://orgmode.org/manual/Easy-templates.html).

After reading Nicolas' points, I see the argument for moving people away
from org-tempo, actually I'm very excited to start using yasnippet. I've
been putting off incorporating it into my workflow for a while but this
thread has finally convinced me to start.

However, I do think the transition could be made a lot smoother for new
users.  The biggest step would be updating the easy-templates page to let
users know they now need to use org-tempo and should consider alternatives
such as yasnippet for more functionality.

Regards,
Kevin

On Mon, Apr 30, 2018 at 6:29 AM Nicolas Goaziou 
wrote:

> Hello,
>
> Bastien  writes:
>
> > Here is what the experience can look like:
> >
> > - Upgrading Emacs or Org (hurray!!)
> > - Trying to hit  > - Thinking your stupid
>
> [...]
>
> I have an issue with this argument: it can be opposed to virtually any
> backward-incompatible change we make. There are actually 10 such changes
> in Org 9.2. Would it makes sense to remove them because some users,
> unfortunately, will encounter a workflow break upon updating Org?
>
> I totally agree this is an issue, yet, we have to move forward. We can
> make UX consistent across releases, but we cannot guarantee 100%
> compatibility at each step. As a data point, I don't know any software
> that preserves the exact same UX after each release -- Firefox, Gnome,
> I'm looking at you! There are unavoidable gotchas. This just means Org
> is still vivid.
>
> > In fact, I'm inclined to ask the real question: if org-tempo is on by
> > default, who will have good reasons to turn it off and why?
>
> This is one problem: only a few will have a reason (good or bad, who
> cares?) to turn it off, e.g., because expansion gets in the way with
> other templating systems. Possibly even fewer will actually turn it off.
> As a consequence, the vast majority of users will keep using " put maintenance burden on us -- instead of trying, and improving
> something else. Inertia...
>
> I already stated the following, sorry for re-iterating. Marking a region
> and wrapping it in some environment is a basic operation Org is expected
> to provide. We already did with `org-emphasize'. Implementing
> programmable templates, even though we are re-using what Emacs ships
> with, is another story.
>
> Org Tempo is a nice tool. I'm not questioning this. It is also almost
> 100% compatible with previous feature. Yet, it competes with external
> Emacs libraries, as capable as itself. Since it is not a feature
> mandatory in Org, why forcing it onto the users? I'm inclined to think
> we shouldn't.
>
> Regards,
>
> --
> Nicolas Goaziou0x80A93738
>
>


Re: [O] No operator defined for property header-args

2017-06-07 Thread Kevin Foley
You're right, I thought because a refresh was needed for #+PROPERTY: it was
also needed for property blocks.  Thanks for your help.

Thanks,
Kevin Foley

On Wed, Jun 7, 2017 at 12:20 PM, Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Kevin Foley <kfole...@gmail.com> writes:
>
> > Ah okay it's my misunderstanding then.  I'm trying to refresh the local
> > setup to apply a different set of header args to that tree.
> >
> > After some research it looks like I should just be calling
> > org-mode-restart.  Does that seem correct?
>
> I don't think you need to refresh anything for node properties. I.e.,
> the new value will be used during next evaluation.
>
>
> Regards,
>
> --
> Nicolas Goaziou
>


Re: [O] No operator defined for property header-args

2017-06-07 Thread Kevin Foley
Ah okay it's my misunderstanding then.  I'm trying to refresh the local
setup to apply a different set of header args to that tree.

After some research it looks like I should just be calling
org-mode-restart.  Does that seem correct?

Thanks,
Kevin


On Tue, Jun 6, 2017 at 8:13 AM Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Kevin Foley <kfole...@gmail.com> writes:
>
> > I've attached an ECM and below is my attempt at the backtrace.  Let me
> know
> > if I missed something.
> >
> > * org-at-property-p()
> > * #[0 "\301 \204 \302\303!\210\304\305!\306 \210\307\310 \311#8\204
> > \302\312 \"\210\313 !\207" [org-columns-current-fmt-compiled
> > org-at-property-p user-error "Not at a property"
> match-string-no-properties
> > 2 org-columns-get-format-and-top-level 3 assoc-string t "No operator
> > defined for property %s" org-columns-compute] 6
> > ("/home/kevin/.emacs.d/lib/org/lisp/org.elc"
> > . 550375) nil]()
> > * apply(#[0 "\301 \204 \302\303!\210\304\305!\306 \210\307\310 \311#8\204
> > \302\312 \"\210\313 !\207" [org-columns-current-fmt-compiled
> > org-at-property-p user-error "Not at a property"
> match-string-no-properties
> > 2 org-columns-get-format-and-top-level 3 assoc-string t "No operator
> > defined for property %s" org-columns-compute] 6
> > ("/home/kevin/.emacs.d/lib/org/lisp/org.elc"
> > . 550375) nil] nil)
> > * org-compute-property-at-point()
> >   funcall-interactively(org-compute-property-at-point)
> >   call-interactively(org-compute-property-at-point)
> >   org-property-action()
> >   funcall-interactively(org-property-action)
> >   call-interactively(org-property-action)
> >   org-ctrl-c-ctrl-c(nil)
> >   funcall-interactively(org-ctrl-c-ctrl-c nil)
> >   call-interactively(org-ctrl-c-ctrl-c nil nil)
> >   command-execute(org-ctrl-c-ctrl-c)
>
> AFAIU, when you are offered the `org-property-action' menu, you press
> "c", for `org-compute-property-at-point'.
>
> As a consequence, the error is expected since there is nothing to
> compute here. What did you expect instead?
>
> Regards,
>
> --
> Nicolas Goaziou
>
-- 
Thanks,
Kevin Foley


Re: [O] No operator defined for property header-args

2017-06-06 Thread Kevin Foley
I've attached an ECM and below is my attempt at the backtrace.  Let me know
if I missed something.

* org-at-property-p()
* #[0 "\301 \204 \302\303!\210\304\305!\306 \210\307\310 \311#8\204
\302\312 \"\210\313 !\207" [org-columns-current-fmt-compiled
org-at-property-p user-error "Not at a property" match-string-no-properties
2 org-columns-get-format-and-top-level 3 assoc-string t "No operator
defined for property %s" org-columns-compute] 6
("/home/kevin/.emacs.d/lib/org/lisp/org.elc"
. 550375) nil]()
* apply(#[0 "\301 \204 \302\303!\210\304\305!\306 \210\307\310 \311#8\204
\302\312 \"\210\313 !\207" [org-columns-current-fmt-compiled
org-at-property-p user-error "Not at a property" match-string-no-properties
2 org-columns-get-format-and-top-level 3 assoc-string t "No operator
defined for property %s" org-columns-compute] 6
("/home/kevin/.emacs.d/lib/org/lisp/org.elc"
. 550375) nil] nil)
* org-compute-property-at-point()
  funcall-interactively(org-compute-property-at-point)
  call-interactively(org-compute-property-at-point)
  org-property-action()
  funcall-interactively(org-property-action)
  call-interactively(org-property-action)
  org-ctrl-c-ctrl-c(nil)
  funcall-interactively(org-ctrl-c-ctrl-c nil)
  call-interactively(org-ctrl-c-ctrl-c nil nil)
  command-execute(org-ctrl-c-ctrl-c)

Thanks,
Kevin Foley

On Mon, Jun 5, 2017 at 5:00 PM, Nicolas Goaziou <m...@nicolasgoaziou.fr>
wrote:

> Hello,
>
> Kevin Foley <kfole...@gmail.com> writes:
>
> > I'm getting the error "No operator defined for property header-args" when
> > trying to run `org-property-action` on the `header-args` property below:
> >
> > * outline header
> > :PROPERTIES:
> > :header-args:bash::tangle yes
> > :END:
> >
> > I'm able to set the same properties using
> >
> > #+PROPERTY: header-args:bash :tangle yes
> >
> > I've tried running `emacs -Q` and get the same error.  I'm using
> > org-version is 9.0.7
>
> I'm not able to reproduce it. Could you post an ECM and a backtrace?
>
> Regards,
>
> --
> Nicolas Goaziou
>


header-args-ecm.org
Description: Binary data


[O] No operator defined for property header-args

2017-06-05 Thread Kevin Foley
I'm getting the error "No operator defined for property header-args" when
trying to run `org-property-action` on the `header-args` property below:

* outline header
:PROPERTIES:
:header-args:bash::tangle yes
:END:

I'm able to set the same properties using

#+PROPERTY: header-args:bash :tangle yes

I've tried running `emacs -Q` and get the same error.  I'm using
org-version is 9.0.7


[O] Bug: Org Agenda Custom Search Excludes Non Active Keywords [9.0.5 (9.0.5-elpa @ c:/emacs/.emacs.d/elpa/org-20170210/)]

2017-03-05 Thread Kevin Foley
I set an agenda command to search for "DONE" todo items
using "/DONE". This search works when selecting "t" from
org-agenda, however when using a custom command with tags-todo it seems non
active TODO
keywords are excluded.

Per the advanced searching page at
http://orgmode.org/worg/org-tutorials/advanced-searching.html non active
keywords should only be excluded when an exclamation point is used, ie.
"/!DONE".

Apologies if I'm misunderstanding something here.

Emacs  : GNU Emacs 25.1.1 (x86_64-w64-mingw32)
 of 2016-11-15
Package: Org mode version 9.0.5 (9.0.5-elpa @
c:/emacs/.emacs.d/elpa/org-20170210/)

current state:
==
(setq
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-speed-command-hook '(org-speed-command-default-hook
org-babel-speed-command-hook)
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-confirm-shell-link-function 'yes-or-no-p
 org-agenda-custom-commands '(("d" "Done tasks" ((tags-todo "/DONE"
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook
change-major-mode-hook org-show-block-all append local] 5]
#[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook
org-babel-show-result-all append local] 5]
org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
org-cycle-show-empty-lines
 org-optimize-window-after-visibility-change)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("id" :follow org-id-open) ("rmail" :follow
org-rmail-open :store org-rmail-store-link)
  ("mhe" :follow org-mhe-open :store org-mhe-store-link) ("irc" :follow
org-irc-visit :store org-irc-store-link)
  ("info" :follow org-info-open :export org-info-export :store
org-info-store-link)
  ("gnus" :follow org-gnus-open :store org-gnus-store-link)
  ("docview" :follow org-docview-open :export org-docview-export :store
org-docview-store-link)
  ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link)
  ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete
org-bbdb-complete-link :store org-bbdb-store-link)
  ("w3m" :store org-w3m-store-link) ("file+sys") ("file+emacs") ("doi"
:follow org--open-doi-link)
  ("elisp" :follow org--open-elisp-link) ("file" :complete
org-file-complete-link)
  ("ftp" :follow (lambda (path) (browse-url (concat "ftp:" path
("help" :follow org--open-help-link)
  ("http" :follow (lambda (path) (browse-url (concat "http:" path
  ("https" :follow (lambda (path) (browse-url (concat "https:" path
  ("mailto" :follow (lambda (path) (browse-url (concat "mailto:;
path
  ("message" :follow (lambda (path) (browse-url (concat "message:"
path
  ("news" :follow (lambda (path) (browse-url (concat "news:; path
("shell" :follow org--open-shell-link))
 org-agenda-files '("~/Documents/Org/test.org")
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 )