help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: how to get around deprecated function


From: Emanuel Berg
Subject: Re: how to get around deprecated function
Date: Tue, 05 May 2015 19:39:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

John Mastro <john.b.mastro@gmail.com> writes:

> Here's a simplified version, which also adds the
> feature that it will use the active region, if any,
> or the current line otherwise.
>
>     (defun append-to-starscratch (beg end)
>       (interactive
>        (if (use-region-p)
>            (list (region-beginning) (region-end))
>          (list (line-beginning-position) (line-end-position))))
>       (let ((str (buffer-substring beg end)))
>         (with-current-buffer (get-buffer-create "*scratch*")
>           (goto-char (point-max))
>           (insert "\n" str))))

Yes, the `line-beginning-position' and
`line-end-position' are good. They are better than
moving point, even when enclosed by `save-excursion'.

I also like the interactive DWIM region/line combo.

Indeed, they say (goto-char (point-max)) should be
used and not (end-of-buffer).

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

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