Seems as function `list-at-point' from thingatpt.el
fails.
To check this, I set a defun foo at the beginning of a
buffer and called check-list functions an them as
given. The result was always nil, but should return the
list.
(defun foo ()
" "
(interactive "*")
(message "%s" "baz"))
(defun check-list-at-point-1 ()
" "
(interactive)
(goto-char 3)
(message "%s" (list-at-point)))
(defun check-list-at-point-2 ()
" "
(interactive)
(goto-char 3)
(message "%s" (form-at-point 'list 'listp)))
AFAIS the error is in
`bounds-of-thing-at-point'
which grasps the right positions during its curse, but
fails to store and deliver them.
For the moment I wrote some simplified, independent
list-handlers, which I forward herewith for discussion.
;;;
(defun separate-list-ar (arg)
" "
(interactive "p")
(unless (looking-at "\\s\(")
(backward-up-list))
(let* ((opoint (point)))
(when (re-search-backward "[^ \t]+" (line-beginning-position) t 1)
(goto-char opoint)
(newline-and-indent))
(push-mark)
(forward-list arg)
(setq opoint (point))
(when (or (looking-at "\\s\)")
(re-search-forward "[^ \t]+" (line-end-position) t 1))
(goto-char opoint)
(save-excursion
(newline-and-indent)))))
(defun separate-and-comment-ar (arg)
"Separate list and save a commented copy of it"
(interactive "p")
(separate-list-ar arg)
(comment-uncomment-line-or-region arg))
(defun mark-list-ar (arg)
" "
(interactive "p")
(unless (looking-at "\\s\(")
(backward-up-list))
(push-mark)
(forward-list arg))
(defun copy-list-ar (arg)
" "
(interactive "p")
(let ((start
(progn
(unless (looking-at "\\s\(")
(backward-up-list))
(push-mark)
(point)))
(end (progn
(forward-list arg)
;; (forward-char 1)
(point))))
(copy-region-as-kill start end)
))
(defun transpose-list-ar ()
(interactive "*")
(when (looking-at "[ \n\t\f]")
(backward-char 1))
(copy-list-ar 1)
(backward-sexp 2)
(let ((start (point)))
(copy-list-ar 1)
(forward-sexp)
(delete-region start (point)))
(insert (concat (cadr kill-ring)"\n"(car kill-ring))))
(defun kill-list-ar (arg)
" "
(interactive "p")
(let ((start
(progn
(unless (looking-at "\\s\(")
(backward-up-list))
(push-mark)
(point)))
(end (progn
(forward-list arg)
(point))))
(kill-region start end)
))
(defun comment-uncomment-line-or-region (&optional arg)
"Comments or uncomments a line according to state before.
With key pressed, continues with next line.
With arg copies and reinserts last line."
(interactive "*P")
(comment-normalize-vars)
(let* ((arg (if arg (prefix-numeric-value arg) 0))
(start (if (and mark-active transient-mark-mode)
(region-beginning)
(line-beginning-position)))
(end (if (and mark-active transient-mark-mode)
(region-end)
(line-end-position)))
(line-to-comment-or-uncomment (buffer-substring-no-properties
(or
start (line-beginning-position))
(or end
(line-end-position)))))
(cond ((eq 1 arg) ;; comment and reinsert
(comment-or-uncomment-region start end)
(indent-according-to-mode)
(end-of-line)
(newline)
(insert line-to-comment-or-uncomment)
(indent-according-to-mode))
((< 1 arg) ;; comment as many lines are given
(while (<= 1 (prefix-numeric-value arg))
(comment-or-uncomment-region (line-beginning-position)
(line-end-position))
(indent-according-to-mode)
(end-of-line)
(forward-line 1)
;; (indent-according-to-mode)
(setq arg (1- arg))))
((and start end)
(comment-or-uncomment-region start end)
(indent-according-to-mode)
(if (eobp)
(progn (newline)
(indent-according-to-mode))
(progn
(forward-line 1)
(indent-according-to-mode))))
(t ;; just one line
(progn (comment-or-uncomment-region (line-beginning-position)
(line-end-position))
(indent-according-to-mode)
(if (eobp)
(progn (newline)
(indent-according-to-mode))
(progn
(forward-line 1)
(indent-according-to-mode))))))))
Any comments welcome.
__
Andreas Roehler
_______________________________________________
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug