From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kyle Meyer Subject: Re: [PATCH] org-sort: Read compare-func in interactive calls Date: Thu, 11 May 2017 21:48:37 -0400 Message-ID: <8737cax2tm.fsf@kyleam.com> References: <871srz5mbr.fsf@kyleam.com> <20170509194750.8974-1-kyle@kyleam.com> <87tw4r12ww.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8zhI-00045u-FT for emacs-orgmode@gnu.org; Thu, 11 May 2017 21:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8zhF-00018A-7I for emacs-orgmode@gnu.org; Thu, 11 May 2017 21:48:48 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:50469 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8zhF-000150-1T for emacs-orgmode@gnu.org; Thu, 11 May 2017 21:48:45 -0400 In-Reply-To: <87tw4r12ww.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: Zhitao Gong , emacs-orgmode@gnu.org Nicolas Goaziou writes: >> * lisp/org-list.el (org-sort-list): Read COMPARE-FUNC when called >> interactively rather than being restricted to the default behavior of >> sort-subr's PREDICATE parameter. Guard prompts for GETKEY-FUNC and >> COMPARE-FUNCTION with called-interactively-p, like >> org-table-sort-lines already did for GETKEY-FUNC. > > Thank you. I have but one comment. Thanks for taking a look. >> + (sort-func >> + (cond >> + ((= dcst ?a) #'string<) >> + ((= dcst ?f) >> + (or compare-func >> + (and (called-interactively-p 'any) > > The above should be avoided. See `called-interactively-p' docstring. The > same applies in other places. Yeah, in order to make org-sort-entries, org-sort-list, and org-table-sort-lines behave the same way with respect to how they read getkey-func and compare-func, I ignored the warning in called-interactively-p's docstring that says it can be "brittle" if a function is advised or being debugged. Instead of adding called-interactively-p to org-sort-entries and org-sort-list, I initially looked at removing called-interactively-p from org-table-sort-lines, but I think that would 1) require changing its behavior for determining the sorting column, and 2) going against org-table-sort-lines's docstring that says no prompting will take place if called from Lisp. So I'm fine removing called-interactively-p from org-table-sort-lines, but I'm not sure how it should behave, particularly with respect to the column prompt. Thoughts? -- Kyle