From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleh Krehel Subject: Is it possible to remove org-completing-read and org-completing-read-no-i? Date: Tue, 28 Jul 2015 17:23:31 +0200 Message-ID: <87bnew487g.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZK6qC-0007iI-K4 for emacs-orgmode@gnu.org; Tue, 28 Jul 2015 11:30:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZK6q9-0000w2-Cm for emacs-orgmode@gnu.org; Tue, 28 Jul 2015 11:30:52 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:34285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZK6q8-0000vW-Ub for emacs-orgmode@gnu.org; Tue, 28 Jul 2015 11:30:49 -0400 Received: by wibud3 with SMTP id ud3so185993994wib.1 for ; Tue, 28 Jul 2015 08:30:47 -0700 (PDT) Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id q19sm19553246wik.16.2015.07.28.08.30.46 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 28 Jul 2015 08:30:46 -0700 (PDT) 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org mode Hi all, I'd like to remove them in favor of using `org-icompleting-read' everywhere (or better yet, `completing-read'). `org-completing-read-no-i' doesn't do much, is called twice and can be replaced with a let binding wrapper. `org-completing-read' could be updated this way: (defmacro with-org-minibuffer-keys (&rest body) "Minibuffer read with SPACE being a normal character." `(let ((enable-recursive-minibuffers t) (minibuffer-local-completion-map (copy-keymap minibuffer-local-completion-map))) (org-defkey minibuffer-local-completion-map " " 'self-insert-command) (org-defkey minibuffer-local-completion-map "?" 'self-insert-command) (org-defkey minibuffer-local-completion-map (kbd "C-c !") 'org-time-stamp-inactive) ,@body)) (with-org-minibuffer-keys (org-icompleting-read args)) This change will simplify the code nicely. One example that bothers me is `org-tags-completion-function': it's essentially a hacky closure that relies on several dynamic variables being set: `org-last-tags-completion-table' and `org-add-colon-after-tag-completion' are implicit arguments to this function. With the proposed change, each use of `org-tags-completion-function' will be in conjunction with `org-icompleting-read'. That means a new function can be written: (defun org-read-tags (tag-list &optional colon) (let ((org-last-tags-completion-table tag-list) (org-add-colon-after-tag-completion colon)) (org-icompleting-read "Tag: " 'org-tags-completion-function ;; ... ))) I think it's a better interface, since the coupling is now made explicit, instead of having to remember to set `org-last-tags-completion-table' and `org-add-colon-after-tag-completion' each time `org-tags-completion-function' is to be used. An even better thing to do would be to use "lexical-binding: t", remove `org-tags-completion-function' and have it be a real closure inside `org-read-tags'. Is there any wish or effort to move Org to lexical-binding? Adding it would allow us to get rid of those dynamic variables and `org-tags-completion-function' altogether and have the lambda enclose on tag-list and colon instead. regards, Oleh