help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any packages using ThingAtPointPlus for activation?


From: Eduardo Ochs
Subject: Re: Any packages using ThingAtPointPlus for activation?
Date: Tue, 3 Jan 2023 03:16:50 -0300

On Mon, 2 Jan 2023 at 07:13, Jean Louis <bugs@gnu.support> wrote:
>
> Dear Drew,
>
> Regarding your library:
> https://www.emacswiki.org/emacs/ThingAtPointPlus
>
> You probably know Hyperbole and how M-RET works in Hyperbole. I like
> the concept and wish to use M-RET in similar fashion, though without
> Hyperbole package, so to jump to various functions by using
> thing-at-point plus. It gives me freedom to easier define what I need,
> and if nothing found I can still include Hyperbole function on the
> end.
>
> The concept to "jump" based on some things at point, is useful. I jump
> faster to various pieces of information.
>
> Here is the preliminary function that shows the concept:
>
> (defun hyperscope-action-button (&optional prefix)
>   (interactive "p")
>   (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point 'uuid)))
>         ;; the above would find UUID in databases or Org files and jump there.
>         ((thing-at-point 'url) (browse-url (thing-at-point 'url)))
>         ;; the above browse the URL
>         ((thing-at-point 'email) (rcd-write-email user-full-name 
> user-mail-address (thing-at-point 'email) (thing-at-point 'email)))
>         ;; the above writes the e-mail to email address found at point
>         ((thing-at-point 'symbol)
>          (let ((symbol (intern (thing-at-point 'symbol))))
>            (cond ((fboundp symbol)
>                   (find-function symbol))
>                  ((boundp symbol)
>                   (find-variable symbol))
>                  (t (rcd-warning-message "Could not find symbol `%s'" 
> symbol)))))
>                  ;; the above finds definition of a function similar like 
> xref but works outside of Emacs Lisp mode
>         ((thing-at-point 'number) (hyperscope-isolate (thing-at-point 
> 'number)))
>         ;; the above would jump to elementary object in Hyperscope database
>         (t (rcd-message "Hyperscope action not defined.")))))
>         ;; Or I get warning
>
> ;; Easy to define global key
> (keymap-global-set "M-RET" #'hyperscope-action-button)
>
> I want to expand the concept by following thinking:
>
> - M-RET -- jump to default function
> - C-u 0 M-RET -- capture thing at point
> - C-u 1 M-RET -- share thing at point
> - C-u 2 M-RET -- etc. etc. etc.
>
> Point of this e-mail:
> ---------------------
>
> Before I continue expanding the concept, it is better I ask you and others 
> about previous work.
>
> Do you know of any existing package(s), apart from Hyperbole, that
> deal in similar way with action keys andjumping based on what is found
> under the point?
>
> On MELPA, I see related packages, that have useful functions:
> https://melpa.org/#/?q=at-point
>
> And M-x package-list-packages did not give me some more relevant
> information about "thing" and "jump".

Hi Jean Louis,

just one comment... `hyperscope-action-button' is written in a way
that I don't like: it doesn't let us inspect what is the thing at
point before doing something with the thing at point, and so it is
hard to debug. I would factor it in at least two functions, and the
lower-level one would be something like this, but I've omitted the
case that tests for interned symbols...

(defun ee-thing-at-point ()
  (cond ((thing-at-point 'symbol) (list 'symbol (thing-at-point 'symbol)))
        ((thing-at-point 'url)    (list 'url    (thing-at-point 'url)))
        ((thing-at-point 'email)  (list 'email  (thing-at-point 'email)))
        ((thing-at-point 'number) (list 'number (thing-at-point 'number)))
))

In eev I have something similar to that, but that classifies the
current buffer into several kinds instead of classifying the thing
around point into several kinds. It is here,

  http://angg.twu.net/eev-current/eev-hlinks.el.html#ee-fhl-main-program
  (find-eev "eev-hlinks.el" "ee-fhl-main-program")

and it is written in a way in which I can replace the code that
interprets the "program" by something more elegant without having to
change the "program" itself... which is good, because I think that the
current interpreter is not very well-written. But the current version
has a debugging mode that is decently good - try `M-1 M-h M-h' to see
what it shows.

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]