From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: [External] : Any packages using ThingAtPointPlus for activation? Date: Thu, 5 Jan 2023 08:42:26 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39096"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.9+54 (af2080d) (2022-11-21) Cc: Drew Adams , Help GNU Emacs To: Eduardo Ochs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 05 09:39:04 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDLmB-0009qf-RT for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 05 Jan 2023 09:39:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDLlU-00073a-HF; Thu, 05 Jan 2023 03:38:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDLlT-00073J-P7 for help-gnu-emacs@gnu.org; Thu, 05 Jan 2023 03:38:19 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pDLlR-0001eb-Ju for help-gnu-emacs@gnu.org; Thu, 05 Jan 2023 03:38:19 -0500 Original-Received: from localhost ([::ffff:102.85.153.82]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000055D52.0000000063B68C59.00005E0F; Thu, 05 Jan 2023 01:37:44 -0700 Mail-Followup-To: Eduardo Ochs , Drew Adams , Help GNU Emacs Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142124 Archived-At: * Eduardo Ochs [2023-01-04 19:05]: > Hi Jean and all, > > for the sake of completeness, here is the prototype that I wrote: > > http://angg.twu.net/elisp/eev-rcd-tap-1.el I have been testing it. Thanks. I am interested in quick, user friendly way of invoking functions with multiple variations by using single key, not necessarily only on thing at point, there are variations involved. A "word" may be special word like database table name, I may need or want to browse the entries straight. I have often functions like: (rcd-db-get-entry "hyobjects" "hyobjects_link" id hs-db) as that one fetch value of column "hyobjects_link" from table "hyobjects" by unique key ID from database "hs-db". And Emacs will not recognize "hyobjects" but my function can do that. General idea is to expand or bypass Hyperbole's usage of a single key to become smart in various context. There is function `read-multiple-choice' (blocking the interface) which can be used for few choices. If there is active region, I wish to choose if to capture it or do what else with it. So I have made `read-multiple-choice' to be automatic: (defun rcd-multiple-choice-by-listo (list rcd-function &optional prompt description quit-on-any) "Run RCD-FUNCTION on results of multiple choice LIST of strings. It uses `q' char to quit thus its value will not be used. PROMPT is optional just as DESCRIPTION. QUIT-ON-ANY will not return to main menu after running the function." (let* ((prompt (or prompt "Choose: ")) (choices '((?q "Quit"))) (key ?b) (quit)) (mapc (lambda (item) (when (= key ?q) (setq key (1+ key))) (push (list key item description) choices) (setq key (1+ key))) (seq-sort 'string< list)) (while (not quit) (let* ((resize-mini-windows t) ;; TODO maybe not needed, rather setting max-mini-window-height? (selection (read-multiple-choice prompt (reverse choices))) (new-key (car selection)) (value (cadr selection))) (setq key new-key) (when (or quit-on-any (= ?q key)) (setq quit t)) (unless (= ?q new-key) (funcall rcd-function value)))))) Then I can do something like: (defun rcd-db-region-choice () (when (region-active-p) (let ((region (rcd-region-string))) (rcd-multiple-choice-by-list '("Search Hyperscope" "Search people" "Capture region" "rgrep") (lambda (arg) (cond ((string= arg "Search Hyperscope") (hyperscope-by-name nil region)) ((string= arg "Search people") (cf-people-by-name region)) ((string= arg "Capture region") (hyperscope-capture-region)) ((string= arg "rgrep") (rgrep-current-word-in-el-project)) (t (message "%s" arg) (sleep-for 2)))) "What to do with region?" nil t)))) The above concept will be added to things at point, as if there is region, there may be special things to choose. That get included: (defun hyperscope-action-button () (interactive) (cond ((region-active-p) (rcd-db-region-choice)) ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point 'uuid))) ((thing-at-point 'url) (browse-url (thing-at-point 'url))) ((thing-at-point 'email) (rcd-write-email user-full-name user-mail-address (thing-at-point 'email) (thing-at-point 'email))) ((and (thing-at-point 'symbol) (boundp (symbol-at-point))) (find-variable (symbol-at-point))) ((and (thing-at-point 'symbol) (fboundp (symbol-at-point))) (find-function (symbol-at-point))) ((thing-at-point 'number) (hyperscope-isolate (thing-at-point 'number))) ((thing-at-point 'word) (cond ((hyperscope-tap-table) (hyperscope-visit-table (thing-at-point 'word))) (t (funcall (cond ((fboundp 'wordnut-search) 'wordnut-search) ((fboundp 'dictionary-search) 'dictionary-search)) (thing-at-point 'word))))) (t (rcd-message "Hyperscope action not defined.")))) (keymap-global-set "M-RET" #'hyperscope-action-button) Concept is decades old from Hyperbole. It is to unify common functions to single key, making the key "smart" by context. Example of contexts: - Cursor in mail mode before the line "--text follows this line--" where line begins with To, Bcc, Cc, then it should try to expand e-mail aliases - Cursor or point on known e-mail address, that exist in database, ask user if to jump to profile or send e-mail? - Cursor on unknown e-mail address, or phone number, or similar, enter in the database first. - Cursor on known phone number, display contact's name, decide if to initiate call, SMS, XMPP, send E-mail, etc. I initiate calls by using: (defun termux-call (number) "Call NUMBER" (let ((command (concat "(am start -a android.intent.action.CALL -d tel:" number))) (termux/send-command command))) -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/