emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: list-at-point


From: Andreas Roehler
Subject: Re: list-at-point
Date: Fri, 13 Oct 2006 18:00:18 +0200
User-agent: Thunderbird 1.5.0.4 (X11/20060516)

martin rudalics schrieb:
> (put 'list 'end-op (lambda () (forward-list 1)))
> (setq thatpt-listconstruktor '\()
> (put 'list 'beginning-op (lambda () (unless (looking-at  (format "%s"
> thatpt-listconstruktor )) (backward-up-list))))

(unless (looking-at "(")) seems simpler.  But to check whether a
character starts a list you should check its syntax as

(eq (char-syntax (char-after)) ?\())

OK.

Tried to make `thatpt-listconstruktor' a customizable
variable, to let the user decide, what should be
conceived as beginning and end of a list. Enabling
strings and regexps here, it was intended to read
databases with, extract arbitrary code etc.

Meanwhile I think its better to create a separate
data-at-point for this.



The idea of thing-at-point is to get the thing if point is before or in
it, or point is after it and not before a thing of the same kind.  What
do you get with point after (foo bar)?  What do you do if point is not
in the range beg..end?

AFAIS old thing-at-point function returned just thatpt, if
anything, nothing different.

Drew Adams wrote `form-nearest-point',
`form-nearest-point-with-bounds' and a lot of things
around it with thatpt+.el.

IMO the problem of old bounds-of-thatpt-function is: it
starts to go forward, not backward, thus multiplying
difficulties, as regexps don't work well from the end.

;;;;;;;;

There is shortcoming in the documentation too.

The docstring of `thing-at-point' says:

,----
| Possibilities include `symbol', `list', `sexp', `defun', `filename', `url',
| `word', `sentence', `whitespace', `line', `page' and others.
`----

"and others" is misleading, as the user may get the
impression, it's up to him to call thatpt with
arbitrary regular names to get working.

In fact it only works, if  either the guesses as

`(intern-soft (format "forward-%s" thing)))'

are successful or the `beginning-op' and `end-op' is set
before.

The user should be averted so far.

;;;;;;;;

Question: What should thatpt return if it finds nothing
appropriate?

I prefer just `nil' at the moment.

Maybe let the user decide? Introduce a customised
return behaviour?

;;;;;;;;

What do you do if scan-lists reports an error?
Will see. I'm going to look at the program a little bit further
 and do some checks.

BTW. Here is s tool for it. With some adaptation it might be useful for others too.

(defun thing-at-point-test-ar ()
 " "
 (interactive)
 (let
     ((oldbuf (current-buffer))
      (atp-list (list 'word-at-point-ar
              'bounds-of-word-at-point-ar
              'sentence-at-point-ar
              'bounds-of-sentence-at-point-ar
              'sexp-at-point-ar
              'bounds-of-sexp-at-point-ar
              'symbol-at-point-ar
              'bounds-of-symbol-at-point-ar
              'url-at-point-ar
              'bounds-of-url-at-point-ar
              'filename-at-point
              'bounds-of-filename-at-point
              )))
   (save-excursion
     (set-buffer (get-buffer-create "thatpt-test"))
     (erase-buffer))
   (dolist (elt atp-list)
     (let ((item (funcall elt)))
   (save-excursion
     (switch-to-buffer "thatpt-test")
     (when (listp item)
(setq item (concat (format "%s" (car item))" "(format "%s" (cadr item)))))
     (insert (concat (format "%s: " elt) item "\n")))
   (switch-to-buffer oldbuf)))))


__
Regards

Andreas Roehler







reply via email to

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