From: Jean Louis <bugs@gnu.support>
To: Nathan Neff <nathan.neff@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Configure Helm Source from org-tags-view
Date: Thu, 8 Aug 2019 23:20:35 +0200 [thread overview]
Message-ID: <20190808212035.GU23122@protected.rcdrun.com> (raw)
In-Reply-To: <CAC=HedCQL=zsRj2AtHCejqp4N1YSCmFFEoboHF+ULNGWO_pJhg@mail.gmail.com>
* Nathan Neff <nathan.neff@gmail.com> [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" "management@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 &optional 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."))))
(global-set-key (kbd "C-x 7 o") 'rcd/org-send-assigned-task)
Some functions may be missing. But that is how I send tasks to my
people, it works well.
next prev parent reply other threads:[~2019-08-08 21:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-08 16:49 Configure Helm Source from org-tags-view Nathan Neff
2019-08-08 19:00 ` Jean Louis
2019-08-08 19:13 ` Jean Louis
2019-08-08 20:03 ` Nathan Neff
2019-08-08 20:23 ` Nathan Neff
2019-08-08 20:30 ` Jean Louis
2019-08-08 20:46 ` Nathan Neff
2019-08-08 21:20 ` Jean Louis [this message]
2019-08-08 20:29 ` Jean Louis
2019-08-09 11:07 ` Adam Porter
2019-08-09 17:57 ` Nathan Neff
2019-08-09 19:13 ` Adam Porter
2019-08-09 21:20 ` Nathan Neff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190808212035.GU23122@protected.rcdrun.com \
--to=bugs@gnu.support \
--cc=emacs-orgmode@gnu.org \
--cc=nathan.neff@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).