unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* delete-horizontal-space and NO-BREAK SPACE
@ 2010-08-23 13:33 Detlev Zundel
  2010-08-23 15:50 ` Drew Adams
  2010-08-23 16:28 ` Andreas Röhler
  0 siblings, 2 replies; 6+ messages in thread
From: Detlev Zundel @ 2010-08-23 13:33 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

more and more often I get emails with NO-BREAK SPACE characters (ascii
160) in them which are used for alignment purposes.  When replying to
such e-mails, I usually have to edit this a lot and wish 'M-\' would
erase the whole stretch of the characters.

Looking up the definition of delete-horizontal-space, it is obvious that
it doesn't do this as it only erases " \t".

Is there another nice function really erasing all space characters
(i.e. chars belonging to the "space" category) or should the funtion be
improved?

Thanks
  Detlev

-- 
Be careful in casting out your devil 'lest you cast out the best thing
about you.
                           -- Friedrich Nietzsche




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: delete-horizontal-space and NO-BREAK SPACE
  2010-08-23 13:33 delete-horizontal-space and NO-BREAK SPACE Detlev Zundel
@ 2010-08-23 15:50 ` Drew Adams
  2010-08-23 16:28 ` Andreas Röhler
  1 sibling, 0 replies; 6+ messages in thread
From: Drew Adams @ 2010-08-23 15:50 UTC (permalink / raw)
  To: 'Detlev Zundel', help-gnu-emacs

> more and more often I get emails with NO-BREAK SPACE characters (ascii
> 160) in them which are used for alignment purposes.  When replying to
> such e-mails, I usually have to edit this a lot and wish 'M-\' would
> erase the whole stretch of the characters.
> 
> Looking up the definition of delete-horizontal-space, it is 
> obvious that it doesn't do this as it only erases " \t".
> 
> Is there another nice function really erasing all space characters
> (i.e. chars belonging to the "space" category) or should the 
> funtion be improved?

I would suggest that you file an enhancement request, via `M-x
report-emacs-bug'. The Emacs developers will then DTRT (decide whether and where
to enhance Emacs for this).

IMO, there should be a user option that controls what "whitespace" is affected
by this and similar commands (e.g. `fixup-whitespace',
`delete-trailing-whitespace', `delete-blank-lines').

And modes and other functions should feel free to bind that option when (they
are sure it is truly) appropriate.

[Yes, I know that some consider it heresy to allow/endorse Lisp binding of user
options. I do not. Sometimes it makes sense for a function to control an option
value, but yes of course, generally the user knows best. If it is problematic
for some given option/context, then value choices can be provided for both
possibilities - some values inform programs not to override/bind. E.g., if
non-nil (or whatever), then just bind to the existing value (essentially a
no-op), respecting the user choice, else do something the program considers more
appropriate.]




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: delete-horizontal-space and NO-BREAK SPACE
  2010-08-23 13:33 delete-horizontal-space and NO-BREAK SPACE Detlev Zundel
  2010-08-23 15:50 ` Drew Adams
@ 2010-08-23 16:28 ` Andreas Röhler
  2010-08-23 21:15   ` Detlev Zundel
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Röhler @ 2010-08-23 16:28 UTC (permalink / raw)
  To: help-gnu-emacs

Am 23.08.2010 15:33, schrieb Detlev Zundel:
> Hi,
>
> more and more often I get emails with NO-BREAK SPACE characters (ascii
> 160) in them which are used for alignment purposes.  When replying to
> such e-mails, I usually have to edit this a lot and wish 'M-\' would
> erase the whole stretch of the characters.
>
> Looking up the definition of delete-horizontal-space, it is obvious that
> it doesn't do this as it only erases " \t".
>
> Is there another nice function really erasing all space characters
> (i.e. chars belonging to the "space" category) or should the funtion be
> improved?
>
> Thanks
>    Detlev
>

Hi,

to get rid of nasty single chars, I use forms like this:

(defun delete-zero-fourteen ()
   "Delete chars ascii octal \\014 "
   (interactive "*")
   (let ((beg (cond ((region-active-p)
		    (region-beginning))
		   (t (point-min))))
	(end (cond ((region-active-p)
		    (region-end))
		   (t (point-max)))))
     (save-excursion
       (goto-char beg)
       (while (re-search-forward (concat (list 12)) end t 1)
	(replace-match "")))))
HTH

Andreas





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: delete-horizontal-space and NO-BREAK SPACE
  2010-08-23 16:28 ` Andreas Röhler
@ 2010-08-23 21:15   ` Detlev Zundel
  2010-08-23 22:11     ` Drew Adams
  2010-08-24  6:16     ` Andreas Röhler
  0 siblings, 2 replies; 6+ messages in thread
From: Detlev Zundel @ 2010-08-23 21:15 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Andreas,


[...]

> to get rid of nasty single chars, I use forms like this:
>
> (defun delete-zero-fourteen ()
>   "Delete chars ascii octal \\014 "
>   (interactive "*")
>   (let ((beg (cond ((region-active-p)
> 		    (region-beginning))
> 		   (t (point-min))))
> 	(end (cond ((region-active-p)
> 		    (region-end))
> 		   (t (point-max)))))
>     (save-excursion
>       (goto-char beg)
>       (while (re-search-forward (concat (list 12)) end t 1)
> 	(replace-match "")))))
> HTH

Thanks for the code but what I really wanted to know is how Emacs itself
handles this.  I have a feeling that this should not need custom code to
handle.  There is a function 'delete-horizontal-space' and I wanted to
know if and how it applies to this specific 'space' also.

When I encounter a problem not too specific to the special case, I
usually try to find out how other people cope with it before inventing
"yet another wheel(tm)".

If nobody else points me to a already supported way of handling my case
I'll follow Drews advise and pose the question to a wider audience.

Thanks!
  Detlev

-- 
NAN - No Acronym Neccessary




^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: delete-horizontal-space and NO-BREAK SPACE
  2010-08-23 21:15   ` Detlev Zundel
@ 2010-08-23 22:11     ` Drew Adams
  2010-08-24  6:16     ` Andreas Röhler
  1 sibling, 0 replies; 6+ messages in thread
From: Drew Adams @ 2010-08-23 22:11 UTC (permalink / raw)
  To: 'Detlev Zundel', help-gnu-emacs

> Thanks for the code but what I really wanted to know is how 
> Emacs itself handles this. ...
> There is a function 'delete-horizontal-space' and I wanted to
> know if and how it applies to this specific 'space' also.

That's easy:

1. C-h f delete-horizontal-space RET

2. Click the link to the library (`simple.el' in this case) where the help text
says the function (`delete-horizontal-space' in this case) is defined.

That takes you directly to the definition of `delete-horizontal-space' (source
code).

> If nobody else points me to a already supported way of 
> handling my case I'll follow Drews advise and pose the question
> to a wider audience.

You will see from its definition code that `delete-horizontal-space' does not
(yet) do what you want wrt non-breaking space. But you already knew that. ;-)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: delete-horizontal-space and NO-BREAK SPACE
  2010-08-23 21:15   ` Detlev Zundel
  2010-08-23 22:11     ` Drew Adams
@ 2010-08-24  6:16     ` Andreas Röhler
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Röhler @ 2010-08-24  6:16 UTC (permalink / raw)
  To: help-gnu-emacs

Am 23.08.2010 23:15, schrieb Detlev Zundel:
> Hi Andreas,
>
>
> [...]
>
>> to get rid of nasty single chars, I use forms like this:
>>
>> (defun delete-zero-fourteen ()
>>    "Delete chars ascii octal \\014 "
>>    (interactive "*")
>>    (let ((beg (cond ((region-active-p)
>> 		    (region-beginning))
>> 		   (t (point-min))))
>> 	(end (cond ((region-active-p)
>> 		    (region-end))
>> 		   (t (point-max)))))
>>      (save-excursion
>>        (goto-char beg)
>>        (while (re-search-forward (concat (list 12)) end t 1)
>> 	(replace-match "")))))
>> HTH
>
> Thanks for the code but what I really wanted to know is how Emacs itself
> handles this.  I have a feeling that this should not need custom code to
> handle.  There is a function 'delete-horizontal-space' and I wanted to
> know if and how it applies to this specific 'space' also.
>
> When I encounter a problem not too specific to the special case, I
> usually try to find out how other people cope with it before inventing
> "yet another wheel(tm)".
>
> If nobody else points me to a already supported way of handling my case
> I'll follow Drews advise and pose the question to a wider audience.
>
> Thanks!
>    Detlev
>

Hi,

some questions remain:

Can't see an  (ascii 160).

Assume you got some character, whose meaning in other context is formatting.

Then it's just a character, who doesn't belong to the mode, you use.

'delete-horizontal-space' is an edit-function, not designed to cure 
encoding-errors.

Presumable you got chars into a text-mode buffer, which are not text.
That may indicate a bug, but must not.

Andreas





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-24  6:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-23 13:33 delete-horizontal-space and NO-BREAK SPACE Detlev Zundel
2010-08-23 15:50 ` Drew Adams
2010-08-23 16:28 ` Andreas Röhler
2010-08-23 21:15   ` Detlev Zundel
2010-08-23 22:11     ` Drew Adams
2010-08-24  6:16     ` Andreas Röhler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).