From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.devel Subject: A widget-based version of find-cmd Date: Fri, 31 May 2019 04:15:16 +0200 Message-ID: <87v9xrfjyj.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="150134"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: Emacs Development Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 31 04:15:44 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hWX55-000cvP-Jg for ged-emacs-devel@m.gmane.org; Fri, 31 May 2019 04:15:43 +0200 Original-Received: from localhost ([127.0.0.1]:33431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWX54-0004ya-Dd for ged-emacs-devel@m.gmane.org; Thu, 30 May 2019 22:15:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWX4w-0004yD-NA for emacs-devel@gnu.org; Thu, 30 May 2019 22:15:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWX4u-0007TL-Ml for emacs-devel@gnu.org; Thu, 30 May 2019 22:15:34 -0400 Original-Received: from mout.web.de ([212.227.15.14]:57979) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWX4s-0007AC-Sk for emacs-devel@gnu.org; Thu, 30 May 2019 22:15:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1559268924; bh=p1/IO1KcoSrtO7DN3+6IGvvUOPBfIOkJZRMlCecx/UA=; h=X-UI-Sender-Class:From:To:Subject:Date; b=SVdhvqSD7WqBZO4UDvNyse9xy2lUb/aqR/I3+KkdObxfi0KI62XKEJWO4MayXclYh xx6ErugyapBhYcU6fo3LxFgCunhhGu9TcSzd39H71o1kDEYMsw5q2RGv4cX0gutm+l El2VBvb2cNRhCIBveqhrg8y47xtwUWIyCvddPzZ8= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([188.110.143.34]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LbZlL-1grRom3Adf-00lAVP; Fri, 31 May 2019 04:15:23 +0200 X-Provags-ID: V03:K1:e2Awpr12q3jOTAnTM+CQcMuD4AoNT5tMS0zL/484T1hEOKubcr0 uDrZUDG7Cghh6HgHu7yKhrEvGRiIBpqOPYhE6jn4ZSAufVUYp7uL+3HzxmtxadMrSng07sv sV6j9LTy7HXuOJx8API2/qHCTLssKlhNt6qErY6FqXXPdiKwofI++324IEEkheKmfEvA4tn 8HIThdzMtuDyd5+gu2YUA== X-UI-Out-Filterresults: notjunk:1;V03:K0:yaAn+WvxzuA=:hSCzeDpH5tsWP7aJWujWkn NUlyVR0euOKZ75vfNM0JXLa2CmkLb2l61OabaI96DJP08gkbbTtjgyU8oALvA9NGdsWHN0MT1 cSqxcS00V1nohC2bi+x9WotZl+Tlh614ClYCWQDWSk8xDpjT45Dly6DBMWrZfZPzuD22VPYtd ydjaDzYw62m+yUjMZ7qoOpydhrUwIt4rn5gHchxSYQ7tVMaS/228jK/nah7x1Lf44QkG4Dz00 jGzo+w7uA/BxKB4qBTXN8q/9dBN+yOfYG2NAKCEPu9rK2P9/hN7fEx65R98WYIyeB8hsaqMz7 7NLXlS2rTBWmKkjDQ14W1m53/b62cPfeBF15nQUEMWCfikJit07Kro+a/vSqqMmv197FfcVyM brkoyNBsPeVBWeTDcnyXXNH/8j6RGd4NzRALP28fU/fZtAHQO1lmdQaztVB8NQv9dhFqJ3V/3 IgUOuNmj/G/2CCkPbS8DbAejC8F1yUbV7LH/kAPHnCM8T3imb3zyP07Lqv3TNLmOw3RZWJdPS oovzwiwJCSFN4Laa6iUZhCn48v4FU7WpiGl7etmDAe3/HxNeyb3p+FV/ADCMw7Ar5x8pwEPIk wHLZ6YU8OkSzmtDjgY/GkHI1Wejm5hSnM+s6n7EKlo8+VJYhx2PzHG+yjfU4b/yFppnQcxFH0 55z2v/Ki79kWkCr7BSUh7Y2BIlH2oLmKo1chwFKoJoJzdEy3WELKO8bf384d5yumH8xpgpxrm 8obDBfhsCLOncSsfOqXp1jxax/lfXNlAZQtf8RKbNz0UgV0ZH9liLbho14HlKVc4F1U7MxaC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.14 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:237174 Archived-At: Hello, I like the idea of find-cmd.el but it's worthless to me since I use find not often enough to remember all the option names, how time specs work etc. That's why I plan a widget-based version where the user can compose the find command by clicking around in a tree of widgets, all guided with categories to choose from, annotations with doc etc. I would like to extend find-cmd cause it already has a collection of syntactical information about find options -- would that be acceptable? Or would it be a better approach to try to somehow extract the documentation of the options from the find man page? Else, I would have to extend find-constituents with the annotations to show in the selection menus. The original `find-cmd' behavior would be untouched, the new widget-based thing would just be an additional fancy interface. I'm currently struggling with the widget stuff however, mostly because I struggle with the documentation. What I basically need is to define a widget type that let's you choose from a list of options. Among them are combiners like "or" that, when chosen, should provide a widget of the same type. My problem is that I run into an infinite recursion. I thought I can avoid that by constructing the widget deferred via :convert-widget but that doesn't help. Maybe :convert-widget is not for that purpose (actually, then I don't get the purpose of :convert-widget from the widget manual). Here is what I have thrown together so far - the basic widget type described above has the name "a": #+begin_src emacs-lisp ;; -*- lexical-binding: t -*- (require 'widget) (require 'find-cmd) (eval-when-compile (require 'wid-edit)) (defvar find-cmd-wg-main-widget nil) (define-widget 'a 'editable-list "Doc..." :value "ignore" :convert-widget (lambda (widget) (widget-put widget :args (cl-flet ((just-true (lambda (_) t)) (value-get-1 (lambda (w) (list 'iname (widget-field-value-get w))))) `((menu-choice :args ,(append (delq nil (mapcar (pcase-lambda ((and `(,name . ,(or (and (pred listp) `(,arity)) (let arity nil))) (let name-string (symbol-name name)))) (ignore name) (and arity (if (zerop arity) `(choice-item ,name-string) `(editable-field :menu-tag ,name-string :validate ,#'just-true :format ,(concat name-string ": %v") :value-get ,#'value-get-1)))) find-constituents)) ;; (mapcar ;; (lambda (combiner) ;; `(a :tag ,(symbol-name combiner))) ;; '(or and not prune)) ))))) widget)) (let ((buf (generate-new-buffer "*Widget Test*"))) (pop-to-buffer buf) (kill-all-local-variables) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) (setq-local find-cmd-wg-main-widget (widget-create 'a)) (use-local-map (let ((map (make-sparse-keymap))) (set-keymap-parent map widget-keymap) (define-key map [(control ?c) (control ?c)] (lambda () (interactive) (message "%s" (apply #'find-cmd (widget-value find-cmd-wg-main-widget))))) map)) (widget-setup)) #+end_src If you comment out the commented stuff, you get the infinite recursion problem. BTW, apropos using C-c C-c, why is cus-edit stealing this key by doing (widget-put (get 'editable-field 'widget-type) :keymap custom-field-keymap) AFAIU the editable-field widget is not only useful for custom? TIA, Michael.