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

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

Re: A possible marker bug in emacs 20.4


From: G Annamalai
Subject: Re: A possible marker bug in emacs 20.4
Date: 06 Mar 2001 11:25:06 +0530
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi,

Well,  I dont know much of elisp.  So just trying to help.

In the function, if all you wanted was to remember the present state
of the buffer (cursor-position, etc) you might be interested in the
function "save-excursion".

C-h f save-excursion gives

<snip>
Save point, mark, and current buffer; execute BODY; restore those things.
Executes BODY just like `progn'.
<snip>

Maybe thats what you are looking for.

Cheers,
anna


"Bingham, Jay" <address@hidden> writes:

> (defun trim-buffer ()
>   "Remove trailing whitespace from the lines in a buffer
> returning point to its original position when finished.
> Returning point to the original position means that it will be between the
> same characters
> that it was between when the function was invoked, unless one or both of the
> characters
> were removed, in which case it will be between the characters immediately
> before and after
> the deleted text.
> Whitespace for the purposes of this function is space, tab, and carriage
> return characters."
>   (interactive)
>   (let ((start-loc (make-marker)))
>     (setq start-loc (point))
>     (goto-char (point-min))
>     (while (and (< (point) (point-max))
>                       (re-search-forward "[ \t^M]*$" nil t))
>       (replace-match "" nil t)
>       (and (< (point) (point-max)) (forward-char)))
>     (not-modified)
>     (goto-char start-loc)))

-- 

If it wasn't for C, we'd be using BASI, PASAL and OBOL. 




reply via email to

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