Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Jean Louis
* Nathan Neff  [2019-08-08 22:47]:
> Hi Jean Louis,
> 
> Thank you for your time and advice - I am trying to spend time
> learning Elisp and more of the underpinnings in org-mode - so your
> advice was very helpful.
> 
> In fact, I found that org-scan-tags is called by org-map-entries -
> org-map-entries can specify a SCOPE of 'agenda (not the same
> as the 'agenda that's provided to org-scan tags).
> 
> So, I got the code down to a one-liner!
> 
> ;; This searches all agenda-files and returns a bunch of
> ;; stuff that I can re-use in Helm
> (org-map-entries 'agenda bkm 'agenda)

Good if it works for you.

Me, I don't need much programming for Org. What I did for me is
sending assignments by email.

#+PROPERTY: ASSIGNED_ALL John

*** Policies on gold prospecting  :staff:
:PROPERTIES:
:CREATED:  [2019-05-11 Sat 11:14]
:ID:   c9c92a1e-7f60-43b0-8dcf-c16ef47dca52
:ASSIGNED: John
:END:

Then if I execute the function, it asks me to send email with some
subject to Ezekiel, and he received the Org heading in the email.

That way I am distributing tasks to people who don't have computer,
they read it on phone and do it.

That is what I did with Org mode

 (setq *rcd-org-members-for-assigned-tasks*
   '((1 "John" "Management" "managem...@example.com" management)

;; Whereby "John" is in :ASSIGNED, then comes email identity, then comes
;; signature and settings for mutt. I use mutt to send auto emails from
;; Emacs.

(defun rcd-org-extract-assigned-member-email-data ()
  "Fetches ASSIGNED individual from subtree and returns the data"
  (let ((assigned (org-entry-get nil "ASSIGNED")))
(if (not assigned)
(let* ((individual (completing-read "Receiver:" 
(assigned-members-complete
  (let ((id (rcd/org-find-assigned-member-id individual)))
(if id (rcd/org-find-assigned-member-email-data id)
  nil)))
  (let ((id (rcd/org-find-assigned-member-id assigned)))
(rcd/org-find-assigned-member-email-data id)

(defun rcd-org-subtree-to-file (signature)
  "Saves subtree to file"
  (org-back-to-heading)
  (let* ((filename (concatenate 'string (getenv "TMPDIR") (rcd/file-timestamp) 
".org")))
(org-copy-subtree)
(find-file-noselect filename)
(with-temp-file filename
  (org-mode)
  (yank)
  (insert "\n\n")
  (insert-file-contents signature)
  )
filename))

(defun rcd/org-find-headline ()
  "Finds current Org headline"
  (org-with-wide-buffer
   (org-back-to-heading t)
   (let ((case-fold-search nil))
 (when (looking-at org-complex-heading-regexp)
   (match-string-no-properties 4)

(defun rcd-org-mutt-send-file (name email subject file  prefix)
  "Uses mutt to quickly send the file"
  (let* ((prefix (if prefix prefix (mutt/prepared-subject)))
 (to (format "\"%s <%s>\"" name email))
 ;; (to (rcd-mutt-escape-string to))
 (subject (concatenate 'string "\"" prefix ": " subject "\""))
 (command (format "mutt -s %s -i \"%s\" %s" subject file to)))
(shell-command command)
(message command)))

(defun mutt/prepared-subject ()
  (let ((subjects '("TASK" "UPDATED" "EXPENSES UPDATED" 
 "POLICY" "READ THIS" "PROJECT" "QUESTION"))
(completion-ignore-case t))
(completing-read "Choose subject: " subjects nil nil)))

(defun assigned-members-complete ()
  (let ((list (loop for i in *rcd-org-members-for-assigned-tasks* collect (cons 
(second i) (second i)
list))

(defun rcd/org-send-assigned-task ()
  "Sends assigned task to designated individual as Org"
  (interactive)
  (let* ((member-data (rcd-org-extract-assigned-member-email-data))
 (id (if member-data (first member-data) nil))
 (signature (if (equal (type-of (symbol-value (fifth member-data))) 
'cons)
(third (symbol-value (fifth member-data))) ""))
 (file (rcd-org-subtree-to-file signature))
 (subject (rcd/org-find-headline))
 (esubject (escape-% subject))
 (ask (unless id (y-or-n-p "No assignment found. Do you want to send it 
by email?")))
 (name (if id (third member-data)))
 ;; (name (if ask (read-from-minibuffer "Name:") name))
 (voice (format "The task '%s' is being sent to '%s'" subject name))
 (email (if id (if (equal (type-of (fourth member-data)) 'cons)
   (car (fourth member-data))
 (fourth member-data
 (email (if ask (cf-search-email (read-from-minibuffer "Search for 
email: ")) email))
 (really (y-or-n-p (format "Do you really want to send it to: %s?" (if 
ask email name)
(if (and really (or id ask))
  (if (string-match "@" email)
(progn
  ;; (message (escape-% subject))
  (speak voice)
  (rcd-org-mutt-send-file name email esubject file))
(message "No email specified"))
  (message "Aborted sending."


Re: [O] Issue with internal links

2019-08-08 Thread Nick Dokos
"Doyley, Marvin M."  writes:

>
> * Testing
> * One
> * Two
>[[*Testing]].   (I also tried [[Testing]] and I got the same error)
>
> Debugger entered--Lisp error: (void-function org-pass-link-to-system)
>   org-pass-link-to-system("*Testing")
>   run-hook-with-args-until-success(org-pass-link-to-system "*Testing")
>   (if (run-hook-with-args-until-success 'org-open-link-functions path) 

org-pass-link-to-system is not a function defined by org mode, AFAICT.
The fact that it's the value of the org-open-link-functions hook reinforces
my belief that at some point in the past, you had defined this function
somewhere and you had included it in the hook; perhaps you lost the function
after an upgrade or a disk failure or ... who knows?

The value of org-open-link-functions is nil in my case, so I'd recommend
you try setting it to that:

 (setq org-open-link-functions nil)

and try following the link. If that works to your satisfaction, then
find the place in your init file or customizations file where
org-pass-link-to-system is added to org-open-link-functions and get
rid of it. Then restart emacs.

HTH.
-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler




Re: [O] Issue with internal links

2019-08-08 Thread Nicolas Goaziou
Hello,

"Doyley, Marvin M."  writes:

> Whenever I double click on an internal link I get the following error
> “void-function org-pass-link-to-system”

The function above doesn't exist in Org base. You may want to
investigate on whatever is adding it to `org-open-link-functions'.

Regards,

-- 
Nicolas Goaziou



Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Nathan Neff
Hi Jean Louis,

Thank you for your time and advice - I am trying to spend time
learning Elisp and more of the underpinnings in org-mode - so your
advice was very helpful.

In fact, I found that org-scan-tags is called by org-map-entries -
org-map-entries can specify a SCOPE of 'agenda (not the same
as the 'agenda that's provided to org-scan tags).

So, I got the code down to a one-liner!

;; This searches all agenda-files and returns a bunch of
;; stuff that I can re-use in Helm
(org-map-entries 'agenda "bkm" 'agenda)

As an aside:
When I run this in org-babel, it gives me a table with two cells:
| foo:Foo.org :bkm: | inbox:
   Formatting Strings:bkm:emacs: |

Why doesn't this table have two *rows* instead of two *cells*?
If anyone knows the fix for this, I'd appreciate it.  It probably has
something to do with the type
of data that's returned by the function, but I'll look into it later.

Thanks,
--Nate



Thanks for your help,
--Nate





On Thu, Aug 8, 2019 at 3:30 PM Jean Louis  wrote:

> * Nathan Neff  [2019-08-08 22:24]:
> > I removed the staff from the beginning of the function call, and changed
> > staff to bar  I also removed the (or (and)) conditions :-)
> >
> > Now, I need to see how to make this function search all agenda files - it
> > seems
> > to work only on the headlines in Foo.org
>
> I am glad that it works somehow for you.
>
> I would not like that type of abuse on myself...
>
> I would just do this:
>
> M-x helm-occur
>
> :staff
>
> and it would be enough.
>


Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Jean Louis
* Nathan Neff  [2019-08-08 22:24]:
> I removed the staff from the beginning of the function call, and changed
> staff to bar  I also removed the (or (and)) conditions :-)
> 
> Now, I need to see how to make this function search all agenda files - it
> seems
> to work only on the headlines in Foo.org

I am glad that it works somehow for you.

I would not like that type of abuse on myself...

I would just do this:

M-x helm-occur

:staff

and it would be enough.



Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Jean Louis
* Nathan Neff  [2019-08-08 22:04]:
> Hi Jean,
> 
> Thank you - however, I can't get this function to return anything.
> 
> org-scan-tags accepts an action, a matcher and a todo-only.
> 
> Code:
> 
> (org-scan-tags 'agenda ;; Action
>   '(staff lambda (todo tags-list level)  ;; Matcher
>(progn
> (setq org-cached-props nil)
> (or (and (member staff tags-list)
> ;; End Matcher
>org--matcher-tags-todo-only) ;; Todo-only
> 
> * To my knowledge, the 'agenda is the action, and the list starting with
> `(staff ) is the matcher.

If you do not have tag "staff" you cannot find anything. So change it
to your own tag. But now after reading I see you have it actually

And function is not going to work outside Org buffer. So I have
evaluated it with M-:

In fact I did following:

(setq a (org-scan-tags 'agenda '(staff lambda (todo tags-list level) (progn 
(setq org-cached-props nil) (or (and (member staff tags-list)  
org--matcher-tags-todo-only))

Then I have inspected 'a' in scratch buffer.

I see that it has various properties for faces, so is not quite the
best output.

> * Why does the tag I'm searching for (staff) appear as the first
> atom in the matcher parameter?  Why isn't it just a lambda?

Me not developer.

> * I don't quite understand what the or and and are doing.  It seems
> like I don't need either of them.

I just tried giving some pointers, so in org-scan-tags is probably the
solution.

When I looked at that function I got fascinated with the type of
programming that I don't like, maybe it is common in Emacs Lisp, but
not what I used to learn from Common Lisp. And I program in Emacs Lisp
in such way that one function evaluates and gives out some results. I
do not work with global variables from within functions.

I was programming in Perl and I stopped the nonsense, but not quite
"just in time". When looking at that function org-scan-tags it looks
to me as Perl. It is LISP without its beauty. I keep functions small
and simple.

My knowledge about "right way" is tiny. All I know is that it looks
ugly as Perl.

I would never do it this way. Not my style.

I would make a function that scans tags and gives out Emacs Lisp
structure, whatever it is.

Then anybody can do with the results whatever they want. We can then
make tags into helm or any other feature.

> My org-agenda-files contains files and I have a headline with the
> tag staff - no quotes, and the function's not returning anything.

Oh, you do have it?

-- don't abuse yourself by looking below

(defvar org--matcher-tags-todo-only nil)

(defun org-scan-tags (action matcher todo-only  start-level)
  "Scan headline tags with inheritance and produce output ACTION.

ACTION can be `sparse-tree' to produce a sparse tree in the current buffer,
or `agenda' to produce an entry list for an agenda view.  It can also be
a Lisp form or a function that should be called at each matched headline, in
this case the return value is a list of all return values from these calls.

MATCHER is a function accepting three arguments, returning
a non-nil value whenever a given set of tags qualifies a headline
for inclusion.  See `org-make-tags-matcher' for more information.
As a special case, it can also be set to t (respectively nil) in
order to match all (respectively none) headline.

When TODO-ONLY is non-nil, only lines with a TODO keyword are
included in the output.

START-LEVEL can be a string with asterisks, reducing the scope to
headlines matching this string."
  (require 'org-agenda)
  (let* ((re (concat "^"
 (if start-level
 ;; Get the correct level to match
 (concat "\\*\\{" (number-to-string start-level) "\\} ")
   org-outline-regexp)
 " *\\(" (regexp-opt org-todo-keywords-1 'words) "\\)?"
 " *\\(.*?\\)\\([ \t]:\\(?:" org-tag-re ":\\)+\\)?[ \t]*$"))
 (props (list 'face 'default
  'done-face 'org-agenda-done
  'undone-face 'default
  'mouse-face 'highlight
  'org-not-done-regexp org-not-done-regexp
  'org-todo-regexp org-todo-regexp
  'org-complex-heading-regexp org-complex-heading-regexp
  'help-echo
  (format "mouse-2 or RET jump to Org file %S"
  (abbreviate-file-name
   (or (buffer-file-name (buffer-base-buffer))
   (buffer-name (buffer-base-buffer)))
 (org-map-continue-from nil)
 lspos tags tags-list
 (tags-alist (list (cons 0 org-file-tags)))
 (llast 0) rtn rtn1 level category i txt
 todo marker entry priority
 ts-date ts-date-type ts-date-pair)
(unless (or 

Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Nathan Neff
Okay, I got this to work in org-babel in a file foo.org
that has headlines like this:

* Foo.org :bar:

#+BEGIN_SRC emacs-lisp

(org-scan-tags 'agenda ;; Action
  '(lambda (todo tags-list level)  ;; Matcher
   (progn
(setq org-cached-props nil)
(member "bar" tags-list))) ;; End
Matcher
   org--matcher-tags-todo-only) ;; Todo-only
#+END_SRC

I removed the "staff" from the beginning of the function call, and changed
staff to "bar"  I also removed the (or (and)) conditions :-)

Now, I need to see how to make this function search all agenda files - it
seems
to work only on the headlines in Foo.org

Thanks,
--Nate

On Thu, Aug 8, 2019 at 3:03 PM Nathan Neff  wrote:

> Hi Jean,
>
> Thank you - however, I can't get this function to return anything.
>
> org-scan-tags accepts an action, a matcher and a todo-only.
>
> Code:
>
> (org-scan-tags 'agenda ;; Action
>   '(staff lambda (todo tags-list level)  ;; Matcher
>(progn
> (setq org-cached-props nil)
> (or (and (member staff tags-list)
> ;; End Matcher
>org--matcher-tags-todo-only) ;; Todo-only
>
> * To my knowledge, the 'agenda is the action, and the list starting with
> `(staff ) is the matcher.
> * Why does the tag I'm searching for ("staff") appear as the first "atom"
> in the
> "matcher" parameter?  Why isn't it just a lambda?
> * I don't quite understand what the "or" and "and" are doing.  It seems
> like
> I don't need either of them.
>
> My org-agenda-files contains files and I have a headline with the tag
> "staff"
> - no quotes, and the function's not returning anything.
>
> Thanks,
> --Nate
>
>
> On Thu, Aug 8, 2019 at 2:13 PM Jean Louis  wrote:
>
>> * Nathan Neff  [2019-08-08 18:50]:
>> > Hello all,
>> >
>> > Has anyone created a Helm source from the results of org-agenda?
>> >
>> > Specifically org-tags-view I think would be a cool Helm source to
>> > configure where the headings that have certain tags could be displayed
>> > by Helm.
>> >
>> > I looked @ the code for org-tags-view and it's fairly straight
>> > forward - however, I think that the function itself is tightly
>> > coupled between finding the results and displaying the results.  In
>> > other words, there's no easy function that I see which would provide
>> > headings that match a tags search that I could use as a Helm source.
>>
>> If tag is 'staff, this below will give structure out:
>>
>> (org-scan-tags 'agenda '(staff lambda (todo tags-list level) (progn
>> (setq org-cached-props nil) (or (and (member staff tags-list)
>> org--matcher-tags-todo-only)
>>
>> Now `org-scan-tags` could be inspected if it constructs some lists,
>> alist, that are somewhat nicer than such output.
>>
>> But that output can be converted to HELM completion.
>>
>> Jean
>>
>


Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Nathan Neff
Hi Jean,

Thank you - however, I can't get this function to return anything.

org-scan-tags accepts an action, a matcher and a todo-only.

Code:

(org-scan-tags 'agenda ;; Action
  '(staff lambda (todo tags-list level)  ;; Matcher
   (progn
(setq org-cached-props nil)
(or (and (member staff tags-list)
;; End Matcher
   org--matcher-tags-todo-only) ;; Todo-only

* To my knowledge, the 'agenda is the action, and the list starting with
`(staff ) is the matcher.
* Why does the tag I'm searching for ("staff") appear as the first "atom"
in the
"matcher" parameter?  Why isn't it just a lambda?
* I don't quite understand what the "or" and "and" are doing.  It seems like
I don't need either of them.

My org-agenda-files contains files and I have a headline with the tag
"staff"
- no quotes, and the function's not returning anything.

Thanks,
--Nate


On Thu, Aug 8, 2019 at 2:13 PM Jean Louis  wrote:

> * Nathan Neff  [2019-08-08 18:50]:
> > Hello all,
> >
> > Has anyone created a Helm source from the results of org-agenda?
> >
> > Specifically org-tags-view I think would be a cool Helm source to
> > configure where the headings that have certain tags could be displayed
> > by Helm.
> >
> > I looked @ the code for org-tags-view and it's fairly straight
> > forward - however, I think that the function itself is tightly
> > coupled between finding the results and displaying the results.  In
> > other words, there's no easy function that I see which would provide
> > headings that match a tags search that I could use as a Helm source.
>
> If tag is 'staff, this below will give structure out:
>
> (org-scan-tags 'agenda '(staff lambda (todo tags-list level) (progn
> (setq org-cached-props nil) (or (and (member staff tags-list)
> org--matcher-tags-todo-only)
>
> Now `org-scan-tags` could be inspected if it constructs some lists,
> alist, that are somewhat nicer than such output.
>
> But that output can be converted to HELM completion.
>
> Jean
>


Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Jean Louis
* Nathan Neff  [2019-08-08 18:50]:
> Hello all,
> 
> Has anyone created a Helm source from the results of org-agenda?
> 
> Specifically org-tags-view I think would be a cool Helm source to
> configure where the headings that have certain tags could be displayed
> by Helm.
> 
> I looked @ the code for org-tags-view and it's fairly straight
> forward - however, I think that the function itself is tightly
> coupled between finding the results and displaying the results.  In
> other words, there's no easy function that I see which would provide
> headings that match a tags search that I could use as a Helm source.

If tag is 'staff, this below will give structure out:

(org-scan-tags 'agenda '(staff lambda (todo tags-list level) (progn
(setq org-cached-props nil) (or (and (member staff tags-list)
org--matcher-tags-todo-only)

Now `org-scan-tags` could be inspected if it constructs some lists,
alist, that are somewhat nicer than such output.

But that output can be converted to HELM completion.

Jean



Re: [O] Agenda: Display projects and 3 todo subtasks

2019-08-08 Thread Nathan Neff
Wow - thanks Adam!

Your stuff is awesome.  org-rifle is incredible.  (I just wish that
it didn't have as many dependencies -- I guess I'm just a bit paranoid).

Thanks,
--Nate


On Thu, Aug 8, 2019 at 10:48 AM Adam Porter  wrote:

> Hi Nathan,
>
> Well, this is an unorthodox solution using org-ql, but it seems to work.
> So, for what it's worth:
>
> #+BEGIN_SRC elisp
>   (let* ((sub-query (lambda ()
>   (save-excursion
> (save-restriction
>   (cons (org-ql--add-markers
> (org-element-headline-parser (line-end-position)))
> (-take 3 (progn
>(org-narrow-to-subtree)
>(org-ql-select nil
>  '(todo)
>  :narrow t
>  :action
> 'element-with-markers
>  (entries (-flatten-n 1 (org-ql-select buffer
>   '(and (tags "PROJECT")
> (not (todo)))
>   :action sub-query
> (org-ql-agenda--agenda nil nil :entries entries))
> #+END_SRC
>
> This produces an agenda-like view showing (I changed "todo" to "TODO" in
> the test file):
>
>   Project 1
> :PROJECT:
>   TODO task 1.1
> :PROJECT:
>   TODO task 1.2
> :PROJECT:
>   TODO task 1.3
> :PROJECT:
>   Project 2
> :PROJECT:
>   TODO task 2.1
> :PROJECT:
>   TODO task 2.2
> :PROJECT:
>   TODO task 2.3
> :PROJECT:
>
> This is a bit awkward, but it's given me an idea about running nested
> queries, so I'll see if I can make that easier.
>
>
>


Re: [O] Configure Helm Source from org-tags-view

2019-08-08 Thread Jean Louis
* Nathan Neff  [2019-08-08 18:50]:
> Hello all,
> 
> Has anyone created a Helm source from the results of org-agenda?
> 
> Specifically org-tags-view I think would be a cool Helm source to
> configure where the headings that have certain tags could be displayed
> by Helm.
> 
> I looked @ the code for org-tags-view and it's fairly straight
> forward - however, I think that the function itself is tightly
> coupled between finding the results and displaying the results.  In
> other words, there's no easy function that I see which would provide
> headings that match a tags search that I could use as a Helm source.

I almost never use the tags view. But now I have tried it. I
understand.

Maybe you find out what is the result or evaluation that creates that
list, maybe it is some list of lists, and it could get ready for HELM
completion with few tweaks.

Jean



Re: [O] Latex single dollar math delimiter question

2019-08-08 Thread emanuel . charpentier
On Sun, 4 Aug 2019, Eric S Fraga had the gall to write :

> By the way, you might be interested in the following configuration
> snippet which makes org insert \(\) when you type a single $ (and a $
> if you type 2 of them in a row).
> 
> #+begin_src emacs-lisp :tangle "esf-org.el"
>   ;; from Nicolas Richard 
>   ;; Date: Fri, 8 Mar 2013 16:23:02 +0100
>   ;; Message-ID: 
>   (defun yf/org-electric-dollar nil
> "When called once, insert \\(\\) and leave point in between.
>   When called twice, replace the previously inserted \\(\\) by one
> $."
>  (interactive)
>  (if (and (looking-at ")") (looking-back "("))
>  (progn (delete-char 2)
> (delete-char -2)
> (insert "$"))
>(insert "\\(\\)")
>(backward-char 2)))
>   (define-key org-mode-map (kbd "$") 'yf/org-electric-dollar)
> #+end_src

A bitt too much reminescent of this xkcd [horror](
https://www.xkcd.com/1806/)...

HTH(BASIWn't)

--
Emmanuel Charpentier





[O] Issue with internal links

2019-08-08 Thread Doyley, Marvin M.
Hi there,

Whenever I double click on an internal link I get the following error 
“void-function org-pass-link-to-system”

Does anybody know how to resolve this.

Thanks
M

PS.  Enclosed is the a back trace for a simple file

* Testing
* One
* Two
   [[*Testing]].   (I also tried [[Testing]] and I got the same error)

Debugger entered--Lisp error: (void-function org-pass-link-to-system)
  org-pass-link-to-system("*Testing")
  run-hook-with-args-until-success(org-pass-link-to-system "*Testing")
  (if (run-hook-with-args-until-success 'org-open-link-functions path) nil (if 
(not arg) (org-mark-ring-push) (switch-to-buffer-other-window 
(org-get-buffer-for-internal-link (current-buffer (let ((destination 
(save-excursion (save-restriction (widen) (if (equal type "radio") 
(org-search-radio-target (org-element-property :path context)) (org-link-search 
(cond ((equal type '"custom-id") (concat "#" path)) ((equal type '"coderef") 
(format "(%s)" path)) (t path)) (and (equal type "fuzzy") (+ 2 
(org-element-property :begin context) (point) (if (and (<= (point-min) 
destination) (>= (point-max) destination)) nil (widen)) (goto-char 
destination)))
  (cond ((equal type "file") (if (string-match "[*?{]" (file-name-nondirectory 
path)) (dired path) (let* ((option (org-element-property :search-option 
context)) (app (org-element-property :application context)) (dedicated-function 
(org-link-get-parameter (if app (concat type "+" app) type) :follow))) (if 
dedicated-function (funcall dedicated-function (concat path (and option (concat 
"::" option (apply (function org-open-file) path (cond (arg) ((equal app 
"emacs") 'emacs) ((equal app "sys") 'system)) (cond ((not option) nil) 
((string-match-p "\\`[0-9]+\\'" option) (list (string-to-number option))) (t 
(list nil option ((functionp (org-link-get-parameter type :follow)) 
(funcall (org-link-get-parameter type :follow) path)) ((member type '("coderef" 
"custom-id" "fuzzy" "radio")) (if (run-hook-with-args-until-success 
'org-open-link-functions path) nil (if (not arg) (org-mark-ring-push) 
(switch-to-buffer-other-window (org-get-buffer-for-internal-link 
(current-buffer (let ((destination (save-excursion (save-restriction 
(widen) (if (equal type "radio") (org-search-radio-target (org-element-property 
:path context)) (org-link-search (cond ((equal type '"custom-id") (concat "#" 
path)) ((equal type '"coderef") (format "(%s)" path)) (t path)) (and (equal 
type "fuzzy") (+ 2 (org-element-property :begin context) (point) (if 
(and (<= (point-min) destination) (>= (point-max) destination)) nil (widen)) 
(goto-char destination (t (browse-url-at-point)))
  (save-current-buffer (set-buffer (or reference-buffer (current-buffer))) 
(cond ((equal type "file") (if (string-match "[*?{]" (file-name-nondirectory 
path)) (dired path) (let* ((option (org-element-property :search-option 
context)) (app (org-element-property :application context)) (dedicated-function 
(org-link-get-parameter (if app (concat type "+" app) type) :follow))) (if 
dedicated-function (funcall dedicated-function (concat path (and option (concat 
"::" option (apply (function org-open-file) path (cond (arg) ((equal app 
"emacs") 'emacs) ((equal app "sys") 'system)) (cond ((not option) nil) 
((string-match-p "\\`[0-9]+\\'" option) (list (string-to-number option))) (t 
(list nil option ((functionp (org-link-get-parameter type :follow)) 
(funcall (org-link-get-parameter type :follow) path)) ((member type '("coderef" 
"custom-id" "fuzzy" "radio")) (if (run-hook-with-args-until-success 
'org-open-link-functions path) nil (if (not arg) (org-mark-ring-push) 
(switch-to-buffer-other-window (org-get-buffer-for-internal-link 
(current-buffer (let ((destination (save-excursion (save-restriction 
(widen) (if (equal type "radio") (org-search-radio-target (org-element-property 
:path context)) (org-link-search (cond ((equal type '"custom-id") (concat "#" 
path)) ((equal type '"coderef") (format "(%s)" path)) (t path)) (and (equal 
type "fuzzy") (+ 2 (org-element-property :begin context) (point) (if 
(and (<= (point-min) destination) (>= (point-max) destination)) nil (widen)) 
(goto-char destination (t (browse-url-at-point
  (let ((type (org-element-property :type context)) (path (org-element-property 
:path context))) (save-current-buffer (set-buffer (or reference-buffer 
(current-buffer))) (cond ((equal type "file") (if (string-match "[*?{]" 
(file-name-nondirectory path)) (dired path) (let* ((option 
(org-element-property :search-option context)) (app (org-element-property 
:application context)) (dedicated-function (org-link-get-parameter (if app 
(concat type "+" app) type) :follow))) (if dedicated-function (funcall 
dedicated-function (concat path (and option (concat "::" option (apply 
(function org-open-file) path (cond (arg) ((equal app "emacs") 'emacs) ((equal 
app "sys") 'system)) (cond ((not option) nil) ((string-match-p "\\`[0-9]+\\'" 

[O] Configure Helm Source from org-tags-view

2019-08-08 Thread Nathan Neff
Hello all,

Has anyone created a Helm source from the results of org-agenda?

Specifically org-tags-view I think would be a cool Helm source to
configure where the headings that have certain tags could be displayed
by Helm.

I looked @ the code for org-tags-view and it's fairly straight forward -
however, I think
that the function itself is tightly coupled between finding the results and
displaying the
results.  In other words, there's no "easy" function that I see which would
provide headings
that match a tags search that I could use as a Helm source.

I think I would need to copy quite a bit of code from org-tags-view into a
different
function to create a Helm source.  Am I missing something?

Has anyone else done something similar?

Thanks,
--Nate


[O] questionable result of Clojure code execution in org babel

2019-08-08 Thread Johannes Brauer
Hi

executing the the following code section in an org-mode file with C-c C-c

#+BEGIN_SRC clojure :results value
(* 3 5)
#+END_SRC

I get

 #+RESULTS:
 : nil15

instead of

 #+RESULTS:
 : 15

Trying the same with emacs-lisp instead of clojure the correct result appears.
My versions:
;; org-mode 9.2.5
;; Aquamacs 3.5  GNU Emacs 25.3.50.1
;; CIDER 0.21.0 (New York), nREPL 0.6.0
;; Clojure 1.9.0, Java 11

Peter Hull, (using nrepl-toggle-message-logging) has figured out the following 
problem:
In org-mode 9.1.9 the sent message looks like:
(-->
 id "8"
 op "eval"
 session "a34917da-541a-4d4a-b790-af8e11020c96"
 time-stamp "2019-08-07 13:18:00.307045105"
 code "(* 1 2 3 4)"
 ns "org-babel-clojure.core"
)

in 9.2.5 it's

(-->
 id "18"
 op "eval"
 session "86281560-e467-47c4-869d-043b03f5c546"
 time-stamp "2019-08-07 12:23:33.769213028"
 code "(ns org-babel-clojure.core)
(* 1 2 3 4)"
)

In the latter we're sending two forms (ns ...) and (* ...) so we get two 
responses. Previously it sent only one and used the ns key in the message to 
set the message.

I am not sure if this list ist the right place to post the problem.

Johannes



Re: [O] Agenda: Display projects and 3 todo subtasks

2019-08-08 Thread Adam Porter
Hi Nathan,

Well, this is an unorthodox solution using org-ql, but it seems to work.
So, for what it's worth:

#+BEGIN_SRC elisp
  (let* ((sub-query (lambda ()
  (save-excursion
(save-restriction
  (cons (org-ql--add-markers 
(org-element-headline-parser (line-end-position)))
(-take 3 (progn
   (org-narrow-to-subtree)
   (org-ql-select nil
 '(todo)
 :narrow t
 :action 
'element-with-markers
 (entries (-flatten-n 1 (org-ql-select buffer
  '(and (tags "PROJECT")
(not (todo)))
  :action sub-query
(org-ql-agenda--agenda nil nil :entries entries))
#+END_SRC

This produces an agenda-like view showing (I changed "todo" to "TODO" in
the test file):

  Project 1:PROJECT:
  TODO task 1.1:PROJECT:
  TODO task 1.2:PROJECT:
  TODO task 1.3:PROJECT:
  Project 2:PROJECT:
  TODO task 2.1:PROJECT:
  TODO task 2.2:PROJECT:
  TODO task 2.3:PROJECT:

This is a bit awkward, but it's given me an idea about running nested
queries, so I'll see if I can make that easier.




[O] ANN: org-ql agenda block support

2019-08-08 Thread Adam Porter
Hi friends,

FYI, I just pushed a new feature to org-ql: custom agenda blocks.  This
allows the use of org-ql queries in custom agenda commands.

https://github.com/alphapapa/org-ql#function-org-ql-block

For example, these two custom commands are equivalent:

#+BEGIN_SRC elisp
  ;; Org Agenda tags-todo version:
  (setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
   ((tags-todo "PRIORITY=\"A\"+Emacs/!SOMEDAY")
(agenda)

  ;; org-ql version:
  (setq org-agenda-custom-commands
'(("ces" "Custom: Agenda and Emacs SOMEDAY [#A] items"
   ((org-ql-block '(and (todo "SOMEDAY")
(tags "Emacs")
(priority "A")))
(agenda)
#+END_SRC

However, the org-ql-block version runs in about 1/5th the time (0.7
seconds compared to 3.45 seconds on my collection of org-agenda-files).

org-ql started as a prototype for a "next-generation agenda" called
org-agenda-ng, but it evolved into its own package, which also provides
tools like org-ql-agenda and org-ql-search that provide agenda-like
views.

Please let me know if you have any feedback.

Thanks,
Adam




[O] TODO or checkbox in tables

2019-08-08 Thread Uwe Brauer



Hi 

I would like to have something like this 



|   | Patient | Nummer | Date | Quantity | Status |
|---+-++--+--+|
| 1 | Smith   | A180106540 | <2018-08-23 Thu> | 67.88 €  | TODO   |


or

|   | Patient | Leistungsart   | Nummer | Date | Quantity | Status |
|---+-+++--+--+|
| 1 | Smith   | Labor Rechnung | A180106540 | <2018-08-23 Thu> | 67.88 €  | [ ] 
   |

Any idea how to do that?

It seems that 
https://orgmode.org/worg/org-tutorials/org-column-view-tutorial.html

 offers one possibility, but is not really what I am looking for,
 because I would like to use a different header for each table which can
 have many rows, I don't want the header to be part of the table.

Thanks

Uwe Brauer 




Re: [O] Bug: Feature request: make org-link emacs wide mode [9.2.5 (9.2.5-elpa @ /home/data1/protected/.emacs.d/elpa/org-20190801/)]

2019-08-08 Thread Jean Louis
* Štěpán Němec  [2019-08-07 10:40]:
> > I would like to request feature so that Org Links can be turned on
> > Emacs wide as org-link-mode. Then links could work in various buffers,
> > and this could make hyperlinking possible from any kinds of files.
> 
> For reference:
> 
> https://github.com/seanohalpin/org-link-minor-mode
> https://github.com/tarsius/orglink

Thank you, I see the concept. Sadly none of those packages work, I
have filed bugs.

Jean