From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [Feature Request] Add an dispatcher command (keybinding) for inserting dynamic blocks Date: Sat, 22 Dec 2018 23:54:25 +0100 Message-ID: <877eg1yxy6.fsf@nicolasgoaziou.fr> References: <871s7lvn4n.fsf@gmail.com> <3332dc93-afb1-0854-6298-06e0939aff3a@free.fr> <87wop1zcwo.fsf@nicolasgoaziou.fr> <87k1k57xt7.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gaqAE-0004DQ-7B for emacs-orgmode@gnu.org; Sat, 22 Dec 2018 17:54:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gaqA9-0006GV-90 for emacs-orgmode@gnu.org; Sat, 22 Dec 2018 17:54:34 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:35997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gaqA8-0006Eo-Vz for emacs-orgmode@gnu.org; Sat, 22 Dec 2018 17:54:29 -0500 In-Reply-To: <87k1k57xt7.fsf@gmail.com> (stardiviner's message of "Thu, 20 Dec 2018 10:10:28 +0800") 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: stardiviner Cc: Thierry Banel , emacs-orgmode@gnu.org Hello, stardiviner writes: > I add code patch in attachment. Nicolas, can you review it? Thank you. Some comments follow. > After running test with "make test", I got some failed test might > related to my code changing. But I checked out the tests, have not > found anywhere invoking the renamed functions. They are not related. > Ran 814 tests, 808 results as expected, 6 unexpected (2018-12-20 09:57:41+0800) > 9 expected failures > > 6 unexpected results: > FAILED ob-D/inhomogeneous_table > FAILED ob-D/list-list-var > FAILED ob-D/list-var > FAILED ob-D/vector-var I don't use D, so I cannot help here. > FAILED test-org-clock/clocktable/lang > FAILED test-org-colview/columns-width This is probably due to a non-default variable leaking in the test. The full error may help. > * lisp/org.el (org-dynamic-block-insert-dispatch): The dispatch command > for inserting dynamic blocks. "New function." is enough. > > (org-dynamic-block-parameters, org-dynamic-block-functions, > org-dynamic-block-types, org-dynamic-block-set-parameters, > org-dynamic-block-get-parameter): New custom option, and new functions > about dynamic blocks. New variables... New functons, etc. > +are updated automatically by a user function. You can use dispatch You need two spaces at the end of sentences. > +command ~org-dynamic-block-insert-dispatch~ which is bind to > +keybinding {{{kbd(C-c C-x i)}}} by default. command ~org-dynamic-block-insert-dispatch~, which is bound to {{{kbd(C-c C-x i)}}} by default. > +For example, {{{kbd(C-c C-x i)}}} + ~clocktable~ inserts a dynamic For example, {{{kbd(C-c C-x i c l o c k t a b l e RET)}}} > +table that updates the work time (see [[*Clocking Work Time]]). > > Dynamic blocks can have names and function parameters. The syntax is > similar to source code block specifications: > diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS > index 811e98147..5bce606f9 100644 > --- a/etc/ORG-NEWS > +++ b/etc/ORG-NEWS > @@ -12,6 +12,11 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. > > * Version 9.2 > ** Incompatible changes > +*** Renamed some dynamic block generate functions name > + > +- Renamed ~org-clock-report~ to ~org-insert-dblock:clocktable~ > +- Renamed ~org-columns-insert-dblock~ to ~org-insert-dblock:columnview~ > + This change will not go in Org 9.2. You need to apply it on top of 9.3, aka, "next" branch. > +*** ~org-dynamic-block-insert-dispatch~ > + > +Use default keybinding =[C-c C-x i]= to run command == > -(defun org-clock-report (&optional arg) > +(defun org-insert-dblock:clocktable (&optional arg) > "Update or create a table containing a report about clocked time. This function is in the wrong namespace. It should be `org-clock-*'. > ;;;###autoload > -(defun org-columns-insert-dblock () > +(defun org-insert-dblock:columnview () Ditto. > -(define-obsolete-function-alias 'org-insert-columns-dblock > - 'org-columns-insert-dblock "Org 9.0") Since you replaced `org-columns-insert-dblock', you need to update the alias, not remove it. You also need to introduce other aliases for the functions you renamed. > +(defcustom org-dynamic-block-parameters > + '(("columnview" :function org-insert-dblock:columnview) > + ("clocktable" :function org-insert-dblock:clocktable)) Why loading them by default? Org clock may not be available. It seems better to initialize to nil and use `org-dynamic-blocks-set-parameter' to fill in the variable in "org-clock.el". > + "An alist of properties that defines all the Org dynamic blocks." > + :type '(alist :tag "dynamic block name" > + :value-type plist) > + :group 'org-block > + :package-version '(Org . "9.1")) It should be "9.3". Also, it is missing, e.g., :safe #'listp. > +(defun org-dynamic-block-get-parameter (type key) > + "Get TYPE dynamic block property for KEY. > +TYPE is a string and KEY is a plist keyword." > + (plist-get > + (cdr (assoc type org-dynamic-block-parameters)) > + key)) > + > +(defun org-dynamic-block-set-parameters (type &rest parameters) > + "Set dynamic block TYPE properties to PARAMETERS. > +PARAMETERS should be :key val pairs. Use it like `org-link-set-parameters'." Missing a space. Also, the second sentence is not helpful. Instead what are the supported keywords? > +(defun org-dynamic-block-insert-dispatch (dblock-type) I don't think "dispatch" should be in the function name. > + "Select and insert an Org type dynamic block. > +This is a dispatching function which prompts for the type of > +dynamic block to insert. It dispatches to functions which names Missing space. > +matches the pattern `org-insert-dblock:*'" I don't think it is true. It dispatches functions listed as :function value. Regards, -- Nicolas Goaziou