From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Louis Subject: Re: Configure Helm Source from org-tags-view Date: Thu, 8 Aug 2019 23:20:35 +0200 Message-ID: <20190808212035.GU23122@protected.rcdrun.com> References: <20190808191313.GW23122@protected.rcdrun.com> <20190808203051.GP23122@protected.rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39422) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvppx-0004JS-3G for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 17:20:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvppv-00079Q-QN for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 17:20:41 -0400 Received: from stw1.rcdrun.com ([217.170.207.13]:33301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hvppv-000795-I8 for emacs-orgmode@gnu.org; Thu, 08 Aug 2019 17:20:39 -0400 Content-Disposition: inline In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nathan Neff Cc: emacs-orgmode * 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" "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.