all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Drew Adams <drew.adams@oracle.com>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: ThingAtPointPlus, and extending things at point
Date: Thu, 5 Jan 2023 11:37:09 +0300	[thread overview]
Message-ID: <Y7aMNfGy41IQp5F3@protected.localdomain> (raw)
In-Reply-To: <SJ0PR10MB54880525EDEA0D3D462FF17DF3F79@SJ0PR10MB5488.namprd10.prod.outlook.com>

The library thingatpt+.el extends thingatpt.el

EmacsWiki: Thing At Point Plus:
https://www.emacswiki.org/emacs/ThingAtPointPlus

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
similar.

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 digit))
			    "-"
			    (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
Adams).

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.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



  parent reply	other threads:[~2023-01-05  8:37 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
2023-01-05  8:37   ` Jean Louis [this message]
2023-01-05 17:00     ` [External] : ThingAtPointPlus, and extending things at point 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=Y7aMNfGy41IQp5F3@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=drew.adams@oracle.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.