From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Re: Add caching to org-buffer-property-keys Date: Tue, 12 Apr 2016 15:55:27 +0200 Message-ID: <2016-04-12T15-52-23@devnull.Karl-Voit.at> References: <2016-03-02T12-21-52@devnull.Karl-Voit.at> <56D73594.6090908@free.fr> Reply-To: Karl Voit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apynF-0004rJ-1I for emacs-orgmode@gnu.org; Tue, 12 Apr 2016 09:55:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1apyn9-0004Ze-AM for emacs-orgmode@gnu.org; Tue, 12 Apr 2016 09:55:48 -0400 Received: from plane.gmane.org ([80.91.229.3]:41200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apyn9-0004ZF-2r for emacs-orgmode@gnu.org; Tue, 12 Apr 2016 09:55:43 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1apyn2-0006Yp-Gm for emacs-orgmode@gnu.org; Tue, 12 Apr 2016 15:55:36 +0200 Received: from friends.grml.info ([136.243.234.19]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 Apr 2016 15:55:36 +0200 Received: from news1142 by friends.grml.info with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 Apr 2016 15:55:36 +0200 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: emacs-orgmode@gnu.org * Thierry Banel wrote: > Nice function! > Maybe a rewrite of (org-read-property-name) calling > (org-entry-properties) could speed up things. > (org-entry-properties) returns an assoc list of the local header properties. OK, great idea. I tried by myself (Elisp noob) and failed: see code below. The code evaluates without complaining but when I use the function, I get asked for a property which gets also correctly written to the property. However, the completion of the property does not work. I'm sure, it's only a small error of mine. Thanks for your help here! ;; version that tries to read only properties of current entry: (defun org-read-entry-property-name () "Read a property name from the current entry (basically a rewrite of org-read-property-name which uses org-entry-properties instead to speed up)" (let ((completion-ignore-case t) (default-prop (or (and (org-at-property-p) (org-match-string-no-properties 2)) org-last-set-property))) (org-completing-read (concat "Property" (if default-prop (concat " [" default-prop "]") "") ": ") ;; ORIGINAL LINE: (mapcar #'list (org-buffer-property-keys nil t t)) (mapcar #'list (org-entry-properties nil nil)) nil nil nil nil default-prop))) (defun my-org-region-to-property (&optional property) (interactive) ;; if no region is defined, do nothing (if (use-region-p) ;; if a region string is found, ask for a property and set property to ;; the string in the region (let ((val (replace-regexp-in-string "\\`[ \t\n]*" "" (replace-regexp-in-string "[ \t\n]*\\'" "" (substring (buffer-string) (- (region-beginning) 1) (region-end)))) ) ;; if none was stated by user, read property from user (prop (or property (org-read-entry-property-name)))) ;; set property (org-set-property prop val)))) -- mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > get Memacs from https://github.com/novoid/Memacs < https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github