all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eduardo Ochs <eduardoochs@gmail.com>
Cc: Drew Adams <drew.adams@oracle.com>,
	Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: [External] : Any packages using ThingAtPointPlus for activation?
Date: Thu, 5 Jan 2023 08:42:26 +0300	[thread overview]
Message-ID: <Y7ZjQuUiFkEf3hxd@protected.localdomain> (raw)
In-Reply-To: <CADs++6hnP3BNKvm7X3WRACG=t8jAxZD1u+vhFQpQ0dDCEnX4Jg@mail.gmail.com>

* Eduardo Ochs <eduardoochs@gmail.com> [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/



  reply	other threads:[~2023-01-05  5:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 10:12 Any packages using ThingAtPointPlus for activation? Jean Louis
2023-01-02 17:08 ` [External] : " Drew Adams
2023-01-03 12:41   ` Jean Louis
2023-01-03 19:54     ` Drew Adams
2023-01-03 20:23       ` Jean Louis
2023-01-03 22:47         ` Drew Adams
2023-01-04  8:46           ` Jean Louis
2023-01-04 15:42             ` Drew Adams
2023-01-04 16:03             ` Eduardo Ochs
2023-01-05  5:42               ` Jean Louis [this message]
2023-01-05  8:37   ` ThingAtPointPlus, and extending things at point Jean Louis
2023-01-05 17:00     ` [External] : " Drew Adams
2023-01-06 15:49       ` Jean Louis
2023-01-06 16:23       ` Jean Louis
2023-01-06 17:30         ` Drew Adams
2023-01-06 17:43           ` Jean Louis
2023-01-06 18:21             ` Drew Adams
2023-01-03  6:16 ` Any packages using ThingAtPointPlus for activation? Eduardo Ochs
2023-01-03 13:10   ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7ZjQuUiFkEf3hxd@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=drew.adams@oracle.com \
    --cc=eduardoochs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.