[Top][All Lists]
[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: |
Thu, 12 Oct 2006 20:43:34 +0200 |
User-agent: |
Thunderbird 1.5.0.4 (X11/20060516) |
martin rudalics schrieb:
> Seems as function `list-at-point' from thingatpt.el
> fails.
>
Currently `list-at-point' does `up-list' followed by `backward-sexp'
followed by another `up-list' which doesn't make sense. Please look at
the attached - largely untested - patch which also tries to handle the
problem that `sexp-at-point' fails at eob.
Thanks a lot caring for this.
Probably its worthwhile to discuss possible changes a
little bit.
Hope it will not--and should not--delay upcoming
release.
What about to shorten `bounds-of-thing-at-point' as
shown below?
It works in the list-context, checked also with word,
symbol, url: everything fine.
;; Lists
;; (put 'list 'end-op (lambda () (up-list 1)))
(put 'list 'end-op (lambda () (forward-list 1)))
(setq thatpt-listconstruktor '\()
;; (put 'list 'beginning-op 'backward-sexp)
(put 'list 'beginning-op (lambda () (unless (looking-at (format "%s"
thatpt-listconstruktor )) (backward-up-list))))
(defun bounds-of-thing-at-point-ar (thing)
"Determine the start and end buffer locations for the THING at point.
THING is a symbol which specifies the kind of syntactic entity you want.
Possibilities include `symbol', `list', `sexp', `defun', `filename', `url',
`word', `sentence', `whitespace', `line', `page' and others."
(let ((beg (progn
(funcall
(or (get thing 'beginning-op)
(lambda () (forward-thing thing -1))))
(point)))
(end
(progn
(funcall
(or (get thing 'end-op)
(lambda () (forward-thing thing 1))))
(point))))
(cons beg end)))
(defun bounds-of-list-at-point-ar (&optional arg)
" "
(interactive "p")
(let ((bounds (bounds-of-thing-at-point-ar 'list)))
(when arg
(message "%s" bounds))
bounds))
(defun list-at-point-ar (&optional arg)
" "
(interactive "p")
(let* ((bounds (bounds-of-thing-at-point-ar 'list))
(list (buffer-substring-no-properties (car bounds) (cdr bounds))))
(when arg
(message "%s" list)
list)))
(defun copy-list-at-point-ar (&optional arg)
" "
(interactive "p")
(let* ((bounds (bounds-of-thing-at-point-ar 'list))
(list (buffer-substring-no-properties (car bounds) (cdr bounds))))
(when arg
(message "%s" list)
(kill-new list))))
(defun kill-list-at-point-ar (&optional arg)
" "
(interactive "p")
(let* ((bounds (bounds-of-thing-at-point-ar 'list))
(start (car bounds))
(end (cdr bounds)))
(kill-region start end)))
;;;;
BTW: Published a bunch of other thing-at-point utility-functions at
gnu-emacs-sources.
Regards
__
Andreas Roehler