[Top][All Lists]

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

ThingAtPointPlus, and extending things at point

From: Jean Louis
Subject: ThingAtPointPlus, and extending things at point
Date: Thu, 5 Jan 2023 11:37:09 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

The library thingatpt+.el extends thingatpt.el

EmacsWiki: Thing At Point Plus:

Though itself is not used extensively in many of your libraries,
Drew. At least I did grep on many.

I am just examining it.

There is 'string and 'string-contents, really good.

Though in various modes 'string should be re-defined to support
various quotes in various modes, let us say in Perl.

I have examined (thing-at-point 'list):

- it works on '(1 "OK" 2) and then I can choose 
  (thing-at-point 'list-contents) to get the elements

- but it does not work on (list 1 2 3), as there I get the element
  `list' by using 'list-contents, that is now what I expected, but OK,
  it is more generalized "list".

The concept of elementary things basically teach computer to recognize
where is the point. 

Things at point are elementary contexts. 

It is possible to teach computer to recognize stuff, and then act upon
it in unified way.

Unification to one key is helpful. No need to remember too many keys. 

Contexts may be expanded by looking into major mode, buffer file name,
position in the file, various elements of the file, TODO states, and

Here is how I have defined thing 'iso-date

First I have defined imperfect ISO date regular expression:

(defvar rcd-rx-iso-date (rx (seq (any digit) (any digit) (any digit) (any 
                            (or (seq "0" (any digit))
                                (seq "1" (any "0-2")))
                            (or (seq (any "0-2") (any digit))
                                (seq "3" (any "0-1"))))
  "Regular expression for ISO date.")

It is imperfect as it does not check for number of days in specific month.

(string-match rcd-rx-iso-date "2023-01-05") ➜ 0
(string-match rcd-rx-iso-date "2023-01-32") ➜ nil
(string-match rcd-rx-iso-date "2023-01-31") ➜ 0w
but incorrect for:
(string-match rcd-rx-iso-date "2023-02-31") ➜ 0

then I defined this:

(defun rcd-tap-iso-date-start ()
  "Move point to the beginning of the ISO date."
  (when (thing-at-point-looking-at rcd-rx-iso-date)
    (goto-char (match-beginning 0))))

(defun rcd-tap-iso-date-end ()
  "Move point to the end of the ISO date."
  (when (thing-at-point-looking-at rcd-rx-iso-date)
    (goto-char (match-end 0))))

and finally definition of thing at point 'iso-date here below:

(put 'iso-date 'beginning-op 'rcd-tap-iso-date-start)
(put 'iso-date 'end-op 'rcd-tap-iso-date-end)

Then on 2023-01-05 the (thing-at-point 'iso-date) gives result:
#("2023-01-05" 0 10 (fontified t))

Thanks to thingatpt.el (by Mike Williams) and thingatpt+.el (by Drew

Why is it useful? It is useful in the context, like having list of
people who communicated on 2023-01-05 or 2023-01-04, 

Joe Doe 2023-01-05
Marry 2023-01-04

to jump quickly to messages and calls from that day.


Take action in Free Software Foundation campaigns:

In support of Richard M. Stallman

reply via email to

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