Documentation
Delivers a set of functions to return, mover over or
manipulate a given THING. THING may be a well known
form as word, paragraph, but also a char class as
`alnum' or a new defined thing.
For example `ar-alnum-atpt' will return all
alpha-numerical chars below and around cursor as a
string. `ar-bounds-
borders of that string as a list and so on.
Here some settings:
(global-set-key [(super \()] 'ar-parentize-
(global-set-key [(super \/)] 'ar-slash-
(global-set-key [(super \<)] 'ar-lesser-
(global-set-key [(super \>)] 'ar-greater-
(global-set-key [(super \[)] 'ar-bracket-
(global-set-key [(super \\)] 'ar-backslash-
(global-set-key [(super \{)] 'ar-brace-
Beside of <super>, the key already tells what to pick.
Quite often used are commands like this:
(global-set-key [(control c)(\")] 'ar-doublequote
(global-set-key [(control c)(\')] 'ar-singlequote
Presently for a given THING the following is
implemented:
ar-THING-atpt
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-end-atpt
ar-THING-
ar-THING-copy-atpt
ar-THING-kill-atpt
ar-THING-
ar-THING-
ar-THING-
ar-THING-sort-atpt
ar-THING-
Beside of the mentioned above, esists still a couple of
functions, whose use is much less probable:
ar-THING-slash-atpt
ar-THING-
ar-THING-
ar-THING-
ar-blok-THING-atpt
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-comment-
ar-commatize-
ar-quote-
ar-THING-
ar-THING-mark-atpt
ar-THING-hide-atpt
ar-THING-show-atpt
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-
ar-THING-trim-atpt
ar-THING-
ar-THING-
ar-underscore-
ar-whitespace-
To see what's implemented, consult contents of
variables at the end of thingatpt-
`ar-atpt-
Call one of the test-functions `C-u ar-th-delimtest'
with come chars in scratch-buffer
or any else changable buffer to get an impression.
The idea comes from Mike Williams
<email address hidden>, author of
thingatpt.el
The goal is to have a set of similar forms. For
example, to provide a word with double-quotes around
it, call ar-doublequote-
may double-quote not just a word, but any object
instrumented here as THING. To make parentheses
around it call ar-parentize-
Move-functions of this package differ from common
behaviour in such, as `ar-forward-
not after THING, but on the last char of
THING. That's in order to enable a call of
thing-at-point functions at the end
position. Otherwise, when cursor stops after word
(THING) as does `forward-word', `ar-word-atpt' would return
nil.
To see other features, maybe try `ar-separate-
or `ar-comment-
list. Try it again with an abstract char-class as
[:alnum:], i.e. try `ar-comment-
`ar-brace-
This utility comes with test-functions which return
the possible results of most functions (exception
are the kill-fns). Call th-test, th-mv-test
or th-delimtest over text. That-delimtest
changes but restores the buffer. Customize the speed
of execution via `ar-th-test-delay'
Diffs to basics of required thingatpt.el:
`bounds-
`ar-th-bounds', which now first searches
backward. As a consequence several
`beginning-op-at' and `end-op-at' constructs had
to be rewritten.
Behavior in general is not validating; i.e. if you
call ar-url-atpt and there is no url, all chars at
point may be picked, which could be part of a
url. Sometimes, however, a kind of validation may be
introduced.
If calling from a program `bounds-
recommended as an entry-point. It delivers a list
with beg and end positions.
In case of trouble, please send me a bug report. Any
ideas and comments welcome.
You might be interested also to visit Drew Adam's
http://
which predates this approach and was helpful writing it.
Thing-at-point delivers a portion of the
buffer. Thats useful, if THING is not as easy to grasp as a word.
For example the first string of an objekt like:
("4[[:punct:] \t\r\n]? [[:punct:] \t\r\n]?C[[:punct:] \t\r\n]?.[[:punct:] \t\r\n]?2[[:punct:] \t\r\n]?4[[:punct:] \t\r\n]?6[[:punct:] \t\r\n]?4[[:punct:] \t\r\n]?/[[:punct:] \t\r\n]?0[[:punct:] \t\r\n]?3[[:punct:] \t\r\n]? [[:punct:] \t\r\n]?B" . "blah blub B")
Remove comments and put the cursor somewhere into the first
string:
`ar-doublequot
enabling yanking it and a lot of further actions.
So far THING is simply picked up.
Different approach combines copying, deleting with delimiting
if region is active:
(global-set-key [(control c) (\")] 'ar-doublequote
will provide doublequotes at beginning and end of region.
With negative argument it deletes the doublequoted portion under
point.
Without any argument these functions return as their simplier
counterparts
With universal argument [(control u)] delimiters --i.e. doublequotes, slashes, whatever-- are stripped.
THING as a buffer substring is determined by
move-functions specified for thingatpt, called
beginning-op-at and end-op-at. Point is stored
after move, beginning and end delivered as pair: as
consed bounds-of-thing. It's easy to write your own
thing-at-point functions that way. You need the
caller and both move forms:
(defun MY-FORM-atpt (&optional arg)
" "
(interactive "p")
(ar-th 'MY-FORM arg))
(put 'MY-FORM 'beginning-op-at
(lambda () MY-FORWARD-
(put 'MY-FORM 'end-op-at
(lambda () MY-BACKWARD-
For example if you want to pick all chars at point
which are written between a string "AAA" and a
"BBB", which may exist as
AAA Luckily detected a lot of things! BBB
After evaluation of
(put 'MY-FORM 'beginning-op-at
(lambda ()
;; step chars of search expression back
(put 'MY-FORM 'end-op-at
(lambda ()
together with the functions definition above, it's ready.
M-x MY-FORM-atpt
(while point inside) you should see:
" Luckily detected a lot of things! "
in the minibuffer.
(?)
Blueprint information
- Status:
- Complete
- Approver:
- Andreas Roehler
- Priority:
- Medium
- Drafter:
- Andreas Roehler
- Direction:
- Approved
- Assignee:
- Andreas Roehler
- Definition:
- Approved
- Series goal:
- Accepted for trunk
- Implementation:
-
Informational
- Milestone target:
-
1.5
- Started by
- Andreas Roehler
- Completed by
- Andreas Roehler