Article View: gnu.emacs.bug
Article #98304fixup-whitespace at end of line
From: Andrew Dennison
Date: Thu, 10 Oct 1991 20:07
Date: Thu, 10 Oct 1991 20:07
57 lines
2478 bytes
2478 bytes
Version: Epoch 3.2.103 of Mon Sep 24 1900 on blt (berkley-unix)
When the point is at the end of the line, I expect fixup-whitespace to
eliminate all spaces. It leaves one. I have a fix:
Old code (from simple.el):
------------------------------------------------------------------------
(defun fixup-whitespace ()
"Fixup white space between objects around point.
Leave one space or none, according to the context."
(interactive "*")
(save-excursion
(delete-horizontal-space)
(if (or (looking-at "^\\|\\s)")
(save-excursion (forward-char -1)
(looking-at "$\\|\\s(\\|\\s'")))
nil
(insert ?\ ))))
------------------------------------------------------------------------
It appears the regexps do not check for end of line. The second one
(looking-at "$\\|\\s(\\|\\s'"))) looks for end of line, but after
backing up a char. So this will normally be true if the point was at
beginning of line initially. But beginning of line is detected in the
1st regexp, so these seems redundant. It also means that this part does
not detect end of line.
Possible Fix:
------------------------------------------------------------------------
;; fix bug at EOL AOD 10/10/91
(defun fixup-whitespace ()
"MY Fixup white space between objects around point.
Leave one space or none, according to the context."
(interactive "*")
(save-excursion
(delete-horizontal-space)
(if (or (looking-at "^\\|\\s)\\|$")
(save-excursion (forward-char -1)
(looking-at "\\s(\\|\\s'")
)
)
nil
(insert ?\ )
)
)
)
------------------------------------------------------------------------
Note the changes to both regexps.
The 1st now checks for end of line.
The second no longer has the redunadant check.
Hope this helps.
Andy Dennison (617) 890-0333
Technical Details
Message-ID:
<9110102007.AA07087@bes.evi.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!evi.COM!andyShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,c677b4b08ea8cebc,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-10-10 13:07:57 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!evi.COM!andy From: andy@evi.COM (Andrew Dennison) Newsgroups: gnu.emacs.bug Subject: fixup-whitespace at end of line Message-ID: <9110102007.AA07087@bes.evi.com> Date: 10 Oct 91 20:07:57 GMT Sender: gnulists@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 57 Approved: bug-gnu-emacs@prep.ai.mit.edu