unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch to change just-one-space
@ 2009-08-13 20:37 Deniz Dogan
  2009-08-13 23:12 ` Xah Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: Deniz Dogan @ 2009-08-13 20:37 UTC (permalink / raw)
  To: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

Hi

I have long wanted to change the behavior of just-one-space to not
only delete spaces and tab characters, but newline characters as well.
Attached is the patch for this change.

I don't think that this is such a controversial modification and I
believe very few user macros will break. If I'm wrong, let me know!

-- 
Deniz Dogan

[-- Attachment #2: just-one-space.el --]
[-- Type: application/octet-stream, Size: 1373 bytes --]

*** lisp/simple.el	10 Aug 2009 16:38:16 -0000	1.1002
--- lisp/simple.el	13 Aug 2009 20:34:48 -0000
*************** If BACKWARD-ONLY is non-nil, only delete
*** 760,778 ****
         (constrain-to-field nil orig-pos)))))
  
  (defun just-one-space (&optional n)
!   "Delete all spaces and tabs around point, leaving one space (or N spaces)."
    (interactive "*p")
    (let ((orig-pos (point)))
!     (skip-chars-backward " \t")
      (constrain-to-field nil orig-pos)
      (dotimes (i (or n 1))
        (if (= (following-char) ?\s)
! 	  (forward-char 1)
! 	(insert ?\s)))
      (delete-region
       (point)
       (progn
!        (skip-chars-forward " \t")
         (constrain-to-field nil orig-pos t)))))
  \f
  (defun beginning-of-buffer (&optional arg)
--- 760,778 ----
         (constrain-to-field nil orig-pos)))))
  
  (defun just-one-space (&optional n)
!   "Delete all whitespace around point, leaving one space (or N spaces)."
    (interactive "*p")
    (let ((orig-pos (point)))
!     (skip-chars-backward " \t\n")
      (constrain-to-field nil orig-pos)
      (dotimes (i (or n 1))
        (if (= (following-char) ?\s)
!             (forward-char 1)
!         (insert ?\s)))
      (delete-region
       (point)
       (progn
!        (skip-chars-forward " \t\n")
         (constrain-to-field nil orig-pos t)))))
  \f
  (defun beginning-of-buffer (&optional arg)

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

* Re: Patch to change just-one-space
  2009-08-13 20:37 Patch to change just-one-space Deniz Dogan
@ 2009-08-13 23:12 ` Xah Lee
  2009-08-13 23:30   ` Deniz Dogan
  2009-08-13 23:19 ` Juri Linkov
  2009-08-14  1:14 ` Miles Bader
  2 siblings, 1 reply; 33+ messages in thread
From: Xah Lee @ 2009-08-13 23:12 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 3439 bytes --]

i share this view.

though, in my experiment, i find that there are often situations where
shrinking all whitespaces including EOL is not convenient. Here's a example:

-----------------------------
   numRep=0
   for couple in findreplace:
c    numRep += s.count(couple[0])
      outtext=s.replace(couple[0],couple[1])
      s=outtext
-----------------------------

where the c is the cursor point.
If you shrink all whitespaces including EOL, the the current line becomes
joined with previous line.

what i find more ideal is this:

when the current line contain non-whitespace chars, then shrink just spaces
and tabs, but if the current line does not contain non-whitespace chars
(it's all white space), then shrink all all spaces, tab, EOL.

the code i've been using is this:

(defun shrink-whitespaces ()
  "Remove white spaces around cursor to just one or none.
If current line contains non-white space chars, then shrink any whitespace
char surrounding cursor to just one space.
If current line does not contain non-white space chars, then remove blank
lines to just one."
  (interactive)
  (let (
        cursor-point
        line-has-meat-p  ; current line contains non-white space chars
        spaceTabNeighbor-p
        whitespace-begin whitespace-end
        space-or-tab-begin space-or-tab-end
        line-begin-pos line-end-pos
        )
    (save-excursion
      ;; todo: might consider whitespace as defined by syntax table, and
also consider whitespace chars in unicode if syntax table doesn't already
considered it.
      (setq cursor-point (point))

      (setq spaceTabNeighbor-p (if (or (looking-at " \\|\t") (looking-back "
\\|\t")) t nil) )
      (move-beginning-of-line 1) (setq line-begin-pos (point) )
      (move-end-of-line 1) (setq line-end-pos (point) )
      ;;       (re-search-backward "\n$") (setq line-begin-pos (point) )
      ;;       (re-search-forward "\n$") (setq line-end-pos (point) )
      (setq line-has-meat-p (if (< 0 (count-matches "[[:graph:]]"
line-begin-pos line-end-pos)) t nil) )
      (goto-char cursor-point)

      (skip-chars-backward "\t ")
      (setq space-or-tab-begin (point))

      (skip-chars-backward "\t \n")
      (setq whitespace-begin (point))

      (goto-char cursor-point)      (skip-chars-forward "\t ")
      (setq space-or-tab-end (point))
      (skip-chars-forward "\t \n")
      (setq whitespace-end (point))
      )


    (if line-has-meat-p
        (progn
          (when spaceTabNeighbor-p
            (delete-region space-or-tab-begin space-or-tab-end)
            (insert " "))
          )

      (progn
;;         (delete-region whitespace-begin whitespace-end)
;;         (insert "\n")
        (delete-blank-lines)
        )
      ;; todo: possibly code my own delete-blank-lines here for better
efficiency, because delete-blank-lines seems complex.
      )
    )
  )

 Xah

On Thu, Aug 13, 2009 at 1:37 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com>wrote:

> Hi
>
> I have long wanted to change the behavior of just-one-space to not
> only delete spaces and tab characters, but newline characters as well.
> Attached is the patch for this change.
>
> I don't think that this is such a controversial modification and I
> believe very few user macros will break. If I'm wrong, let me know!
>
> --
> Deniz Dogan
>



-- 
 Xah
∑ http://xahlee.org/

[-- Attachment #2: Type: text/html, Size: 4956 bytes --]

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

* Re: Patch to change just-one-space
  2009-08-13 20:37 Patch to change just-one-space Deniz Dogan
  2009-08-13 23:12 ` Xah Lee
@ 2009-08-13 23:19 ` Juri Linkov
  2009-08-13 23:33   ` Deniz Dogan
  2009-08-14  1:14 ` Miles Bader
  2 siblings, 1 reply; 33+ messages in thread
From: Juri Linkov @ 2009-08-13 23:19 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

> I have long wanted to change the behavior of just-one-space to not
> only delete spaces and tab characters, but newline characters as well.
> Attached is the patch for this change.
>
> I don't think that this is such a controversial modification and I
> believe very few user macros will break. If I'm wrong, let me know!

No, it's a controversial change.  Just imagine typing M-SPC at the end
of the paragraph.  It will join the current paragraph with the next
paragraph.  IOW, it will work as two commands `just-one-space' and
`delete-blank-lines' combined.  I don't think users will appreciate
such change.

Also we can't guarantee that some code won't break with your change.
For instance, try doing the same in the command `delete-horizontal-space'
(i.e. adding \n to `skip-chars-...') and see how it breaks
paragraph-filling commands.  The same bad effect is possible
for `just-one-space'.

However, your proposed change could be useful when its additional
functionality is requested intentionally, e.g. with a prefix key:
`C-u M-SPC'.

-- 
Juri Linkov
http://www.jurta.org/emacs/




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

* Re: Patch to change just-one-space
  2009-08-13 23:12 ` Xah Lee
@ 2009-08-13 23:30   ` Deniz Dogan
  2009-08-13 23:35     ` Daniel Colascione
  2009-08-14  2:24     ` Xah Lee
  0 siblings, 2 replies; 33+ messages in thread
From: Deniz Dogan @ 2009-08-13 23:30 UTC (permalink / raw)
  To: xahlee; +Cc: Emacs-Devel devel

2009/8/14 Xah Lee <xahlee@gmail.com>:
> i share this view.
> though, in my experiment, i find that there are often situations where
> shrinking all whitespaces including EOL is not convenient. Here's a example:
> -----------------------------
>    numRep=0
>    for couple in findreplace:
> c    numRep += s.count(couple[0])
>       outtext=s.replace(couple[0],couple[1])
>       s=outtext
> -----------------------------
> where the c is the cursor point.
> If you shrink all whitespaces including EOL, the the current line becomes
> joined with previous line.
> what i find more ideal is this:
> when the current line contain non-whitespace chars, then shrink just spaces
> and tabs, but if the current line does not contain non-whitespace chars
> (it's all white space), then shrink all all spaces, tab, EOL.
> the code i've been using is this:
> [snip code]

Not a bad idea. I'd like to take your idea and revise it a bit: If
there are only whitespace characters characters between point and EOL,
nuke including newlines. Otherwise, nuke excluding newlines.

What do you think?

-- 
Deniz Dogan




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

* Re: Patch to change just-one-space
  2009-08-13 23:19 ` Juri Linkov
@ 2009-08-13 23:33   ` Deniz Dogan
  2009-08-14  2:10     ` Stephen J. Turnbull
  0 siblings, 1 reply; 33+ messages in thread
From: Deniz Dogan @ 2009-08-13 23:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Emacs-Devel devel

2009/8/14 Juri Linkov <juri@jurta.org>:
>> I have long wanted to change the behavior of just-one-space to not
>> only delete spaces and tab characters, but newline characters as well.
>> Attached is the patch for this change.
>>
>> I don't think that this is such a controversial modification and I
>> believe very few user macros will break. If I'm wrong, let me know!
>
> No, it's a controversial change.  Just imagine typing M-SPC at the end
> of the paragraph.

That's exactly why I wrote this change, because that's how I use my
own version of M-SPC. I very rarely use the version that's in CVS now.

-- 
Deniz Dogan




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

* Re: Patch to change just-one-space
  2009-08-13 23:30   ` Deniz Dogan
@ 2009-08-13 23:35     ` Daniel Colascione
  2009-08-13 23:37       ` Deniz Dogan
  2009-12-31 20:55       ` Deniz Dogan
  2009-08-14  2:24     ` Xah Lee
  1 sibling, 2 replies; 33+ messages in thread
From: Daniel Colascione @ 2009-08-13 23:35 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

On Aug 13, 2009, at 7:30 PM, Deniz Dogan wrote:
> Not a bad idea. I'd like to take your idea and revise it a bit: If
> there are only whitespace characters characters between point and EOL,
> nuke including newlines. Otherwise, nuke excluding newlines.

just-one-space with a negative prefix argument is currently  
meaningless (more precisely, negative arguments are treated as 0). Why  
not make a negative argument mean "kill including newlines"? That way,  
you can just whack M-- M-SPC to get the behavior you want.




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

* Re: Patch to change just-one-space
  2009-08-13 23:35     ` Daniel Colascione
@ 2009-08-13 23:37       ` Deniz Dogan
  2009-08-14  0:51         ` Robert J. Chassell
  2009-12-31 20:55       ` Deniz Dogan
  1 sibling, 1 reply; 33+ messages in thread
From: Deniz Dogan @ 2009-08-13 23:37 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: Emacs-Devel devel

2009/8/14 Daniel Colascione <danc@merrillpress.com>:
> On Aug 13, 2009, at 7:30 PM, Deniz Dogan wrote:
>>
>> Not a bad idea. I'd like to take your idea and revise it a bit: If
>> there are only whitespace characters characters between point and EOL,
>> nuke including newlines. Otherwise, nuke excluding newlines.
>
> just-one-space with a negative prefix argument is currently meaningless
> (more precisely, negative arguments are treated as 0). Why not make a
> negative argument mean "kill including newlines"? That way, you can just
> whack M-- M-SPC to get the behavior you want.
>

If no one else has a problem with that behavior, I'd be all for it.
Let's see what people decide that this alternative version of
just-on-space should act like first.

-- 
Deniz Dogan




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

* Re: Patch to change just-one-space
  2009-08-13 23:37       ` Deniz Dogan
@ 2009-08-14  0:51         ` Robert J. Chassell
  2009-08-14  0:58           ` Deniz Dogan
  2009-08-14 10:37           ` Teemu Likonen
  0 siblings, 2 replies; 33+ messages in thread
From: Robert J. Chassell @ 2009-08-14  0:51 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: emacs-devel

    If no one else has a problem with that behavior, I'd be all for it.
    Let's see what people decide that this alternative version of
    just-on-space should act like first.

I'm against the change because it joins the current line with the
previous line.

I do not use just-one-space very often but I do use it occasionally and
the change would make it impossible for me to use it since I do not like
visual lines lookiing different from actual lines.

-- 
    Robert J. Chassell                          
    bob@rattlesnake.com                         bob@gnu.org
    http://www.rattlesnake.com                  http://www.teak.cc




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

* Re: Patch to change just-one-space
  2009-08-14  0:51         ` Robert J. Chassell
@ 2009-08-14  0:58           ` Deniz Dogan
  2009-08-14 10:37           ` Teemu Likonen
  1 sibling, 0 replies; 33+ messages in thread
From: Deniz Dogan @ 2009-08-14  0:58 UTC (permalink / raw)
  To: Robert J. Chassell; +Cc: emacs-devel

2009/8/14 Robert J. Chassell <bob@rattlesnake.com>:
>    If no one else has a problem with that behavior, I'd be all for it.
>    Let's see what people decide that this alternative version of
>    just-on-space should act like first.
>
> I'm against the change because it joins the current line with the
> previous line.

I was referring to Daniel's suggestion to make M-- M-SPC act like I
(or Xah) had suggested. M-- M-SPC currently does nothing different
than only M-SPC and is thus "unused".

> I do not use just-one-space very often but I do use it occasionally and
> the change would make it impossible for me to use it since I do not like
> visual lines lookiing different from actual lines.

I'm afraid I don't follow. AFAICS, the change doesn't have to do with
visual lines at all.

-- 
Deniz Dogan




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

* Re: Patch to change just-one-space
  2009-08-13 20:37 Patch to change just-one-space Deniz Dogan
  2009-08-13 23:12 ` Xah Lee
  2009-08-13 23:19 ` Juri Linkov
@ 2009-08-14  1:14 ` Miles Bader
  2 siblings, 0 replies; 33+ messages in thread
From: Miles Bader @ 2009-08-14  1:14 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

Deniz Dogan <deniz.a.m.dogan@gmail.com> writes:
> I have long wanted to change the behavior of just-one-space to not
> only delete spaces and tab characters, but newline characters as well.
>
> I don't think that this is such a controversial modification

It dramatically changes the behavior of the command.

In particular, just-one-space is currently a convenient way to shrink
whitespace at the end of a line.

There are no-doubt situations where such behavior would be desirable
(e.g., typing in a filled paragraph) -- but it certainly not in all
situations.  E.g, I often use just-one-space in source code...

-Miles

-- 
Religion, n. A daughter of Hope and Fear, explaining to Ignorance the nature
of the Unknowable.




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

* Re: Patch to change just-one-space
  2009-08-13 23:33   ` Deniz Dogan
@ 2009-08-14  2:10     ` Stephen J. Turnbull
  2009-08-14  6:59       ` Deniz Dogan
  2009-08-14 15:12       ` Stefan Monnier
  0 siblings, 2 replies; 33+ messages in thread
From: Stephen J. Turnbull @ 2009-08-14  2:10 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Juri Linkov, Emacs-Devel devel

Deniz Dogan writes:
 > 2009/8/14 Juri Linkov <juri@jurta.org>:

 > > No, it's a controversial change.  Just imagine typing M-SPC at the end
 > > of the paragraph.
 > 
 > That's exactly why I wrote this change, because that's how I use my
 > own version of M-SPC. I very rarely use the version that's in CVS now.

I use the current definition a lot; usage patterns vary, it seems.

In your typical use there are *no* non-newline spaces?  Or are you of
the non-TeX school where you represent a paragraph break by "\n " or
"\n\t" or so?

I think that, at least in TeX style (ie, paragraph break is
represented by "\n\n" with no ident, also used by various "structured
text" formats), this probably would unpleasantly surprise many people.

It seems to me that a more flexible and discoverable (and to you
equivalent, up to default keybindings) idea would be to define
`paragraph-join' and `paragraph-break', and bind the former to M-SPC.





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

* Re: Patch to change just-one-space
  2009-08-13 23:30   ` Deniz Dogan
  2009-08-13 23:35     ` Daniel Colascione
@ 2009-08-14  2:24     ` Xah Lee
  2009-08-14  6:53       ` Deniz Dogan
  2009-08-14  8:05       ` Patch to change just-one-space David Kastrup
  1 sibling, 2 replies; 33+ messages in thread
From: Xah Lee @ 2009-08-14  2:24 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 2299 bytes --]

On Thu, Aug 13, 2009 at 4:30 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com>wrote:

> 2009/8/14 Xah Lee <xahlee@gmail.com>:
> > i share this view.
> > though, in my experiment, i find that there are often situations where
> > shrinking all whitespaces including EOL is not convenient. Here's a
> example:
> > -----------------------------
> >    numRep=0
> >    for couple in findreplace:
> > c    numRep += s.count(couple[0])
> >       outtext=s.replace(couple[0],couple[1])
> >       s=outtext
> > -----------------------------
> > where the c is the cursor point.
> > If you shrink all whitespaces including EOL, the the current line becomes
> > joined with previous line.
> > what i find more ideal is this:
> > when the current line contain non-whitespace chars, then shrink just
> spaces
> > and tabs, but if the current line does not contain non-whitespace chars
> > (it's all white space), then shrink all all spaces, tab, EOL.
> > the code i've been using is this:
> > [snip code]
>
> Not a bad idea. I'd like to take your idea and revise it a bit: If
> there are only whitespace characters characters between point and EOL,
> nuke including newlines. Otherwise, nuke excluding newlines.
>
> What do you think?
>

i think that'd bring the next non-whitespace line to the current line,
right?

but in general, considering this thread in whole, i share your view with
merging just-one-space with delete-blank-lines, and the behavior be
depending on context. Something like a shrink-whitespace-dwim.

I feel there are too many small functions on shrinking white spaces, esp
those with a shortcut.
e.g. C-x C-o for delete-blank-lines and just-one-space with M-SPC.

i think that these can be merged into a single dwim version with a single
shortcut, because i think most of the time context can correctly guess the
desired behavior.

i think this applies to few other emacs editing functions for user
convenience. One example i came to is about the 9 or so commands on letter
case changing. Some work on word, some on region... with transient-mark-mode
on now, the region versions could be merged. The lower case and upper case
and cap first versions can also be merged, i think, into one dwim version
that just cycles.

thanks.

  Xah
☄

[-- Attachment #2: Type: text/html, Size: 2932 bytes --]

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

* Re: Patch to change just-one-space
  2009-08-14  2:24     ` Xah Lee
@ 2009-08-14  6:53       ` Deniz Dogan
  2009-08-14 15:26         ` capitalize-dwim (was: Patch to change just-one-space) Stefan Monnier
  2009-08-14  8:05       ` Patch to change just-one-space David Kastrup
  1 sibling, 1 reply; 33+ messages in thread
From: Deniz Dogan @ 2009-08-14  6:53 UTC (permalink / raw)
  To: xahlee; +Cc: Emacs-Devel devel

2009/8/14 Xah Lee <xahlee@gmail.com>:
> i think that'd bring the next non-whitespace line to the current line,
> right?
> but in general, considering this thread in whole, i share your view with
> merging just-one-space with delete-blank-lines, and the behavior be
> depending on context. Something like a shrink-whitespace-dwim.
> I feel there are too many small functions on shrinking white spaces, esp
> those with a shortcut.
> e.g. C-x C-o for delete-blank-lines and just-one-space with M-SPC.
> i think that these can be merged into a single dwim version with a single
> shortcut, because i think most of the time context can correctly guess the
> desired behavior.
> i think this applies to few other emacs editing functions for user
> convenience. One example i came to is about the 9 or so commands on letter
> case changing. Some work on word, some on region... with transient-mark-mode
> on now, the region versions could be merged. The lower case and upper case
> and cap first versions can also be merged, i think, into one dwim version
> that just cycles.
> thanks.
>   Xah
> ☄
>

I agree. E.g. upcase-word, downcase-word and capitalize-word could be
made to work on the region as well if active.

-- 
Deniz Dogan




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

* Re: Patch to change just-one-space
  2009-08-14  2:10     ` Stephen J. Turnbull
@ 2009-08-14  6:59       ` Deniz Dogan
  2009-08-14 12:19         ` Andreas Roehler
  2009-08-14 17:10         ` Stephen J. Turnbull
  2009-08-14 15:12       ` Stefan Monnier
  1 sibling, 2 replies; 33+ messages in thread
From: Deniz Dogan @ 2009-08-14  6:59 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: Juri Linkov, Emacs-Devel devel

2009/8/14 Stephen J. Turnbull <stephen@xemacs.org>:
> Deniz Dogan writes:
>  > 2009/8/14 Juri Linkov <juri@jurta.org>:
>
>  > > No, it's a controversial change.  Just imagine typing M-SPC at the end
>  > > of the paragraph.
>  >
>  > That's exactly why I wrote this change, because that's how I use my
>  > own version of M-SPC. I very rarely use the version that's in CVS now.
>
> I use the current definition a lot; usage patterns vary, it seems.
>
> In your typical use there are *no* non-newline spaces?

No, it is usually a combination of spaces and newlines, e.g. in:

<div>
  <p>
  c <a href="#">Hello</a>
  </p>
</div>

...where point is at "c". Then I'd just merge the lines using M-SPC
DEL or M-0 M-SPC. Then I would probably do it again:

<div>
  <p><a href="#">Hello</a>c
  </p>
</div>

...where point is at "c". The result:

<div>
  <p><a href="#">Hello</a></p>
</div>

> It seems to me that a more flexible and discoverable (and to you
> equivalent, up to default keybindings) idea would be to define
> `paragraph-join' and `paragraph-break', and bind the former to M-SPC.

Sounds interesting. So basically we would make `paragraph-join' the
same as "my" version of `just-one-space'? Or did you have something
different in mind?

-- 
Deniz Dogan




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

* Re: Patch to change just-one-space
  2009-08-14  2:24     ` Xah Lee
  2009-08-14  6:53       ` Deniz Dogan
@ 2009-08-14  8:05       ` David Kastrup
  1 sibling, 0 replies; 33+ messages in thread
From: David Kastrup @ 2009-08-14  8:05 UTC (permalink / raw)
  To: emacs-devel

Xah Lee <xahlee@gmail.com> writes:

> i think that'd bring the next non-whitespace line to the current line, right?
>
> but in general, considering this thread in whole, i share your view
> with merging just-one-space with delete-blank-lines, and the behavior
> be depending on context. Something like a shrink-whitespace-dwim.

dwim-kind functions are more often than not acting up a nuisance in
keyboard macros.  Even C-k can be tiresome in that context.

-- 
David Kastrup





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

* Re: Patch to change just-one-space
  2009-08-14  0:51         ` Robert J. Chassell
  2009-08-14  0:58           ` Deniz Dogan
@ 2009-08-14 10:37           ` Teemu Likonen
  1 sibling, 0 replies; 33+ messages in thread
From: Teemu Likonen @ 2009-08-14 10:37 UTC (permalink / raw)
  To: Robert J. Chassell; +Cc: emacs-devel, Deniz Dogan

On 2009-08-14 00:51 (UTC), Robert J. Chassell wrote:
> I'm against the change because it joins the current line with the
> previous line.
>
> I do not use just-one-space very often but I do use it occasionally
> and the change would make it impossible for me to use it since I do
> not like visual lines lookiing different from actual lines.

I use just-one-space often and I very much want it to operate only on
vertical spaces. So in that I'm against this patch. I don't mind if
negative prefix arguments do something "vertical" too.




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

* Re: Patch to change just-one-space
  2009-08-14  6:59       ` Deniz Dogan
@ 2009-08-14 12:19         ` Andreas Roehler
  2009-08-14 17:10         ` Stephen J. Turnbull
  1 sibling, 0 replies; 33+ messages in thread
From: Andreas Roehler @ 2009-08-14 12:19 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Juri Linkov, Stephen J. Turnbull, emacs-devel

Deniz Dogan wrote:
> 2009/8/14 Stephen J. Turnbull <stephen@xemacs.org>:
>> Deniz Dogan writes:
>>  > 2009/8/14 Juri Linkov <juri@jurta.org>:
>>
>>  > > No, it's a controversial change.  Just imagine typing M-SPC at the end
>>  > > of the paragraph.
>>  >
>>  > That's exactly why I wrote this change, because that's how I use my
>>  > own version of M-SPC. I very rarely use the version that's in CVS now.
>>
>> I use the current definition a lot; usage patterns vary, it seems.
>>
>> In your typical use there are *no* non-newline spaces?
> 
> No, it is usually a combination of spaces and newlines, e.g. in:
> 
> <div>
>   <p>
>   c <a href="#">Hello</a>
>   </p>
> </div>
> 
> ...where point is at "c". Then I'd just merge the lines using M-SPC
> DEL or M-0 M-SPC. Then I would probably do it again:
> 
> <div>
>   <p><a href="#">Hello</a>c
>   </p>
> </div>
> 
> ...where point is at "c". The result:
> 
> <div>
>   <p><a href="#">Hello</a></p>
> </div>
> 
>> It seems to me that a more flexible and discoverable (and to you
>> equivalent, up to default keybindings) idea would be to define
>> `paragraph-join' and `paragraph-break', and bind the former to M-SPC.
> 
> Sounds interesting. So basically we would make `paragraph-join' the
> same as "my" version of `just-one-space'? Or did you have something
> different in mind?
> 


Hi,

I use a similar thing quite often and instead of
fixup-whitespace. Its a useful feature IMO.

Here original behaviour is available via arg.

(defun my-fixup-whitespace (&optional arg)
  "Fixup white space between objects around point.
Leave one space or none, according to the context.
With ARG, don't kill \\r\\n\\f"
  (interactive "*P")
  (save-excursion
    (if (eq 4 (prefix-numeric-value arg))
	(delete-horizontal-space)
      ;; 2007-11-28 a.roehler@web.de changed section start
      (unless (bolp)
	(skip-chars-backward " \t\r\n\f"))
      (let ((start (point)))
      (skip-chars-forward " \t\r\n\f")
      (delete-region start (point)))
    ;; 2007-11-28 a.roehler@web.de changed section end
    (if (or (looking-at "^\\|\\s)")
	    (save-excursion (forward-char -1)
			    (looking-at "$\\|\\s(\\|\\s'")))
	nil
      (insert ? )))))

;;;;





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

* Re: Patch to change just-one-space
  2009-08-14  2:10     ` Stephen J. Turnbull
  2009-08-14  6:59       ` Deniz Dogan
@ 2009-08-14 15:12       ` Stefan Monnier
  2009-08-14 15:16         ` Lennart Borgman
  1 sibling, 1 reply; 33+ messages in thread
From: Stefan Monnier @ 2009-08-14 15:12 UTC (permalink / raw)
  To: Stephen J. Turnbull; +Cc: Juri Linkov, Emacs-Devel devel, Deniz Dogan

> It seems to me that a more flexible and discoverable (and to you
> equivalent, up to default keybindings) idea would be to define
> `paragraph-join' and `paragraph-break', and bind the former to M-SPC.

Along similar lines, I currently use C-u M-j to do the reverse of M-j
(i.e. it joins lines, but additionally removes any comment-starter that
might have gotten in the way).


        Stefan




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

* Re: Patch to change just-one-space
  2009-08-14 15:12       ` Stefan Monnier
@ 2009-08-14 15:16         ` Lennart Borgman
  0 siblings, 0 replies; 33+ messages in thread
From: Lennart Borgman @ 2009-08-14 15:16 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: Juri Linkov, Stephen J. Turnbull, Deniz Dogan, Emacs-Devel devel

On Fri, Aug 14, 2009 at 5:12 PM, Stefan Monnier<monnier@iro.umontreal.ca> wrote:

> Along similar lines, I currently use C-u M-j to do the reverse of M-j
> (i.e. it joins lines, but additionally removes any comment-starter that
> might have gotten in the way).

Could you please add that code to Emacs ...?




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

* capitalize-dwim (was: Patch to change just-one-space)
  2009-08-14  6:53       ` Deniz Dogan
@ 2009-08-14 15:26         ` Stefan Monnier
  2009-08-14 15:36           ` Xah Lee
  0 siblings, 1 reply; 33+ messages in thread
From: Stefan Monnier @ 2009-08-14 15:26 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Emacs-Devel devel

>> case changing. Some work on word, some on region... with
>> transient-mark-mode on now, the region versions could be merged.

It's worth a try, indeed.

>> The lower case and upper case and cap first versions can also be
>> merged, i think, into one dwim version that just cycles.

I doubt this would work: I very often use M-u, or M-c repeatedly to
apply the change to a bunch of words: assuming the first word is
all-lowercase, what should your new command do on the second invocation:
apply the same change to the second word or cycle the capitalization
style on the first word?


        Stefan




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

* Re: capitalize-dwim (was: Patch to change just-one-space)
  2009-08-14 15:26         ` capitalize-dwim (was: Patch to change just-one-space) Stefan Monnier
@ 2009-08-14 15:36           ` Xah Lee
  2009-08-14 16:33             ` capitalize-dwim joakim
  0 siblings, 1 reply; 33+ messages in thread
From: Xah Lee @ 2009-08-14 15:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs-Devel devel, Deniz Dogan

[-- Attachment #1: Type: text/plain, Size: 2320 bytes --]

On Fri, Aug 14, 2009 at 8:26 AM, Stefan Monnier <monnier@iro.umontreal.ca>wrote:

> >> case changing. Some work on word, some on region... with
> >> transient-mark-mode on now, the region versions could be merged.
>
> It's worth a try, indeed.
>
> >> The lower case and upper case and cap first versions can also be
> >> merged, i think, into one dwim version that just cycles.
>
> I doubt this would work: I very often use M-u, or M-c repeatedly to
> apply the change to a bunch of words: assuming the first word is
> all-lowercase, what should your new command do on the second invocation:
> apply the same change to the second word or cycle the capitalization
> style on the first word?


the code i've been using cycle the case of the first letter, on current
word, or region if there's one.

here's the code i've been using for about 2 years.
Andreas Politz and Nikolaj Schumacher had helped in the code.

(defun toggle-letter-case ()
  "Toggle the letter case of current word or text selection.
Toggles from 3 cases: UPPER CASE, lower case, Title Case,
in that cyclic order."
(interactive)
(let (pos1 pos2 (deactivate-mark nil) (case-fold-search nil))
  (if (and transient-mark-mode mark-active)
      (setq pos1 (region-beginning)
            pos2 (region-end))
    (setq pos1 (car (bounds-of-thing-at-point 'word))
          pos2 (cdr (bounds-of-thing-at-point 'word))))

  (when (not (eq last-command this-command))
    (save-excursion
      (goto-char pos1)
      (cond
       ((looking-at "[[:lower:]][[:lower:]]") (put this-command 'state "all
lower"))
       ((looking-at "[[:upper:]][[:upper:]]") (put this-command 'state "all
caps") )
       ((looking-at "[[:upper:]][[:lower:]]") (put this-command 'state "init
caps") )
       (t (put this-command 'state "all lower") )
       )
      )
    )

  (cond
   ((string= "all lower" (get this-command 'state))
    (upcase-initials-region pos1 pos2) (put this-command 'state "init
caps"))
   ((string= "init caps" (get this-command 'state))
    (upcase-region pos1 pos2) (put this-command 'state "all caps"))
   ((string= "all caps" (get this-command 'state))
    (downcase-region pos1 pos2) (put this-command 'state "all lower"))
   )
)
)

some logic on why i find this useful i wrote about here:
  http://xahlee.org/emacs/modernization_upcase-word.html

 Xah

[-- Attachment #2: Type: text/html, Size: 3555 bytes --]

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

* Re: capitalize-dwim
  2009-08-14 15:36           ` Xah Lee
@ 2009-08-14 16:33             ` joakim
  2009-08-15  2:31               ` capitalize-dwim Richard Stallman
  0 siblings, 1 reply; 33+ messages in thread
From: joakim @ 2009-08-14 16:33 UTC (permalink / raw)
  To: xahlee; +Cc: Deniz Dogan, Stefan Monnier, Emacs-Devel devel

Xah Lee <xahlee@gmail.com> writes:

> On Fri, Aug 14, 2009 at 8:26 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>     >> case changing. Some work on word, some on region... with
>     >> transient-mark-mode on now, the region versions could be merged.
>    
>     It's worth a try, indeed.
>    
>     >> The lower case and upper case and cap first versions can also be
>     >> merged, i think, into one dwim version that just cycles.
>    
>     I doubt this would work: I very often use M-u, or M-c repeatedly to
>     apply the change to a bunch of words: assuming the first word is
>     all-lowercase, what should your new command do on the second invocation:
>     apply the same change to the second word or cycle the capitalization
>     style on the first word?
>
>  
> the code i've been using cycle the case of the first letter, on current word, or region if there's one.
>
> here's the code i've been using for about 2 years.
> Andreas Politz and Nikolaj Schumacher had helped in the code.
>
> (defun toggle-letter-case ()
>   "Toggle the letter case of current word or text selection.
> Toggles from 3 cases: UPPER CASE, lower case, Title Case,

Maybe it could also toggle the case of the character under cursor? I
find it useful when working with misspelled CamelCase identifiers.

> in that cyclic order."
> (interactive)
> (let (pos1 pos2 (deactivate-mark nil) (case-fold-search nil))
>   (if (and transient-mark-mode mark-active)
>       (setq pos1 (region-beginning)
>             pos2 (region-end))
>     (setq pos1 (car (bounds-of-thing-at-point 'word))
>           pos2 (cdr (bounds-of-thing-at-point 'word))))
>
>   (when (not (eq last-command this-command))
>     (save-excursion
>       (goto-char pos1)
>       (cond
>        ((looking-at "[[:lower:]][[:lower:]]") (put this-command 'state "all lower"))
>        ((looking-at "[[:upper:]][[:upper:]]") (put this-command 'state "all caps") )
>        ((looking-at "[[:upper:]][[:lower:]]") (put this-command 'state "init caps") )
>        (t (put this-command 'state "all lower") )
>        )
>       )
>     )
>
>   (cond
>    ((string= "all lower" (get this-command 'state))
>     (upcase-initials-region pos1 pos2) (put this-command 'state "init caps"))
>    ((string= "init caps" (get this-command 'state))
>     (upcase-region pos1 pos2) (put this-command 'state "all caps"))
>    ((string= "all caps" (get this-command 'state))
>     (downcase-region pos1 pos2) (put this-command 'state "all lower"))
>    )
> )
> )
>
> some logic on why i find this useful i wrote about here:
>   http://xahlee.org/emacs/modernization_upcase-word.html
>
>  Xah
>
-- 
Joakim Verona




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

* Re: Patch to change just-one-space
  2009-08-14  6:59       ` Deniz Dogan
  2009-08-14 12:19         ` Andreas Roehler
@ 2009-08-14 17:10         ` Stephen J. Turnbull
  1 sibling, 0 replies; 33+ messages in thread
From: Stephen J. Turnbull @ 2009-08-14 17:10 UTC (permalink / raw)
  To: Deniz Dogan; +Cc: Juri Linkov, Emacs-Devel devel

Deniz Dogan writes:

 > > It seems to me that a more flexible and discoverable (and to you
 > > equivalent, up to default keybindings) idea would be to define
 > > `paragraph-join' and `paragraph-break', and bind the former to M-SPC.
 > 
 > Sounds interesting. So basically we would make `paragraph-join' the
 > same as "my" version of `just-one-space'? Or did you have something
 > different in mind?

Well, the idea would be that paragraph-join might eat the "moral
equivalent of whitespace, both horizontal and vertical" in the current
mode.  Eg, as Stefan describes in Lisp mode, paragraph-join at `-!-'
would DTRT:

;; This is a comment.
;; -!-
;; This is a closely related comment.

In something like html-mode, it might go so far as to eat "</p><p>",
which I would find highly objectionable if `just-one-space' did it.
It could (maybe) eat ^L too, something else that I would definitely be
upset if `just-one-space' did it.




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

* Re: capitalize-dwim
  2009-08-14 16:33             ` capitalize-dwim joakim
@ 2009-08-15  2:31               ` Richard Stallman
  0 siblings, 0 replies; 33+ messages in thread
From: Richard Stallman @ 2009-08-15  2:31 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel, monnier, deniz.a.m.dogan

It is a useful feature that the word case commands can apply to
successive words when repeated.  That feature must not be broken
or replaced with toggling.




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

* Re: Patch to change just-one-space
  2009-08-13 23:35     ` Daniel Colascione
  2009-08-13 23:37       ` Deniz Dogan
@ 2009-12-31 20:55       ` Deniz Dogan
  2010-11-22 20:35         ` Deniz Dogan
  2010-11-22 22:16         ` Stefan Monnier
  1 sibling, 2 replies; 33+ messages in thread
From: Deniz Dogan @ 2009-12-31 20:55 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: xahlee, Emacs-Devel devel

[-- Attachment #1: Type: text/plain, Size: 877 bytes --]

2009/8/14 Daniel Colascione <danc@merrillpress.com>:
> On Aug 13, 2009, at 7:30 PM, Deniz Dogan wrote:
>>
>> Not a bad idea. I'd like to take your idea and revise it a bit: If
>> there are only whitespace characters characters between point and EOL,
>> nuke including newlines. Otherwise, nuke excluding newlines.
>
> just-one-space with a negative prefix argument is currently meaningless
> (more precisely, negative arguments are treated as 0). Why not make a
> negative argument mean "kill including newlines"? That way, you can just
> whack M-- M-SPC to get the behavior you want.
>

Attached is a bzr bundle which does this. If the user passes the
argument -N, it will remove any whitespace characters (spaces, tabs,
carriage returns, newlines) and leave N spaces. Unfortunately I
couldn't think of a good way to make e.g. "M-- M-0 M-SPC" leave 0
spaces.

-- 
Deniz Dogan

[-- Attachment #2: just-one-space-negative-argument.txt --]
[-- Type: text/plain, Size: 2924 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: deniz.a.m.dogan@gmail.com-20091231205248-\
#   w839hdjykp7buf2h
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
# testament_sha1: 6a061e3480db7d5854f2d1d911820f89d5e26063
# timestamp: 2009-12-31 21:52:56 +0100
# base_revision_id: lekktu@gmail.com-20091229182933-172o63gm6ve7s3gi
# 
# Begin patch
=== modified file 'lisp/simple.el'
--- lisp/simple.el	2009-12-12 17:01:03 +0000
+++ lisp/simple.el	2009-12-31 20:52:48 +0000
@@ -768,10 +768,14 @@
        (constrain-to-field nil orig-pos)))))
 
 (defun just-one-space (&optional n)
-  "Delete all spaces and tabs around point, leaving one space (or N spaces)."
+  "Delete all spaces and tabs around point, leaving one space (or
+N spaces).  If N is negative, deletes carriage return and
+linefeed characters as well."
   (interactive "*p")
-  (let ((orig-pos (point)))
-    (skip-chars-backward " \t")
+  (let ((orig-pos (point))
+        (skip-characters (if (< n 0) " \t\n\r" " \t"))
+        (n (abs n)))
+    (skip-chars-backward skip-characters)
     (constrain-to-field nil orig-pos)
     (dotimes (i (or n 1))
       (if (= (following-char) ?\s)
@@ -780,7 +784,7 @@
     (delete-region
      (point)
      (progn
-       (skip-chars-forward " \t")
+       (skip-chars-forward skip-characters)
        (constrain-to-field nil orig-pos t)))))
 \f
 (defun beginning-of-buffer (&optional arg)

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWeooGREAAcRfgEwQUGf/91Yj
AAS////wUAQGu3aGd5CrKOCUQUzUyMARoaU8mNT1PUmmjDUGgykxJsm0T0immRoZBoDIAADEIJoS
n6m1M0p6NGo0NqeoNGTQGgykZGpmp6npPUNqAAAAAACSiYhT9JqfqaRsk9TEep5QeoAAA4KNpFA/
OZVTa9ijbGljtPvOIP2RNudsMnX0gjBNtOp3z5+3zK/0bH6TKKqRHqlsj9ItDy5jRy1LFXD6mnso
nPu1NM3QdT9keXpHh2z5Vw8Wxxi7AMGDed7wN9RwrxzG2y3c5NOaNiYgomK+Ksx8ZjomErKZd+ix
s6d6TuIfxInIIUuV+sxXMLHA1mujyEzpBDiUSm+TaVMluhQAzoGwg98QH7wzHsRORBgykZDIRKHV
TCAn6/r6q5C3xu4TeXP0AumwgRgLVuPb5IWapJVN520O1wtOcIJVGZL7M5B8yFYLEB4QVoB0gwMU
KBS2gCM15AJmLg+kGpmk2ybWJsmDgJmWBuaMUCuBmg2GJo51BEwZoCnSpaxqg36DjcLhQNbJkAfv
NOJYLc+mi7kyWR3GqoGFJuDzZiwSecZqpXWaLdlCxrTZqDKPQLZMh7Bc5EMBvHKC3jU6pG+VMAcK
jmbAPNuH6DJGuZHgdA11oOOrMdMFyDsOCAtRbrhaKiWMwaTuNyo0p0sqMXcUYqikKgTqsfln9hy2
3+/IOu7x4czMmV1AEPOPhK9WK9ZVjUVj0OvBo/FE3ODRZWZR18i5Uh1CENx18LwtEfLtNlfcBO5Z
agxJIcdLhpUqCWXPgXGo3Z3YG6wgL9W8VBJ5gxXbKnsCD3DOZIi0ItoLBdos01BNvdwK9caaEpc3
sa+sSedWQ2S3E7C2e10ZyPsJeiSZ7k54dFzb4bHK4I8LmcYsaIJl211EzNUAzqa6hU1VQCidfvUE
E0Jphisnww78czKVzkStxaiorbbclDfqYtcClNKD0a79+WQnAwvcxLScwHluISHLy7YKdM1aQyAp
IizF9CMbswvZU3aDBaxVvmki80UqWMf6nFmSR+t5CsQvR5SmzqHOhnS8l33aIBEhCMIeEhYBO6Eh
Wj2cYaZ0WrvFoUOByZuEMaEAa0Jrkhh0HOQ1/TEOH91toI5k7yyBG81nfiNKXzkJHHU0Xf2K1QkT
DQ5sqAQFAZj10AE+ZaAiEijw6preqs9qVpsBUhXRnQWRBlSpZMmyfxckUNvFMFWtIwKdLHCVtUqe
Xadlt25OdHAgDmwwRCu4MHzrxqBjsfKgmAgpyQFE97s2yYgQhyNNkajnhx8FeA+3oCFh1qUVQtrV
4HJNlpojk7v6C6U3w7AHkO67TbgGh8QLwHPsOHIXx2FDjz8QOuykrYM/txeg8zQ5Y4AaQapkFNTa
XG6YMgBFgf/i7kinChIdRQMiIA==

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

* Re: Patch to change just-one-space
  2009-12-31 20:55       ` Deniz Dogan
@ 2010-11-22 20:35         ` Deniz Dogan
  2010-11-22 22:16         ` Stefan Monnier
  1 sibling, 0 replies; 33+ messages in thread
From: Deniz Dogan @ 2010-11-22 20:35 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: xahlee, Emacs-Devel devel

2009/12/31 Deniz Dogan <deniz.a.m.dogan@gmail.com>:
> 2009/8/14 Daniel Colascione <danc@merrillpress.com>:
>> On Aug 13, 2009, at 7:30 PM, Deniz Dogan wrote:
>>>
>>> Not a bad idea. I'd like to take your idea and revise it a bit: If
>>> there are only whitespace characters characters between point and EOL,
>>> nuke including newlines. Otherwise, nuke excluding newlines.
>>
>> just-one-space with a negative prefix argument is currently meaningless
>> (more precisely, negative arguments are treated as 0). Why not make a
>> negative argument mean "kill including newlines"? That way, you can just
>> whack M-- M-SPC to get the behavior you want.
>>
>
> Attached is a bzr bundle which does this. If the user passes the
> argument -N, it will remove any whitespace characters (spaces, tabs,
> carriage returns, newlines) and leave N spaces. Unfortunately I
> couldn't think of a good way to make e.g. "M-- M-0 M-SPC" leave 0
> spaces.
>

Almost a year has passed and this has probably been forgotten. Would
anyone mind if we make this change?

I do feel that it's not entirely semantic to change the behavior of
the keybinding this drastically with just a negative argument, but I
definitely think it's useful enough to think about.

-- 
Deniz Dogan



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

* Re: Patch to change just-one-space
  2009-12-31 20:55       ` Deniz Dogan
  2010-11-22 20:35         ` Deniz Dogan
@ 2010-11-22 22:16         ` Stefan Monnier
  2010-11-23  8:29           ` Tassilo Horn
  1 sibling, 1 reply; 33+ messages in thread
From: Stefan Monnier @ 2010-11-22 22:16 UTC (permalink / raw)
  To: Emacs-Devel devel; +Cc: xahlee, Daniel Colascione, Deniz Dogan

> Attached is a bzr bundle which does this. If the user passes the
> argument -N, it will remove any whitespace characters (spaces, tabs,
> carriage returns, newlines) and leave N spaces. Unfortunately I
> couldn't think of a good way to make e.g. "M-- M-0 M-SPC" leave 0
> spaces.

Any objection to such a change?  Removing newlines sounds OK to me, but
I don't use just-one-space, so I don't have a good feeling for what
other useful meaning could be used for a negative argument.


        Stefan


> Deniz Dogan
> # Bazaar merge directive format 2 (Bazaar 0.90)
> # revision_id: deniz.a.m.dogan@gmail.com-20091231205248-\
> #   w839hdjykp7buf2h
> # target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
> # testament_sha1: 6a061e3480db7d5854f2d1d911820f89d5e26063
> # timestamp: 2009-12-31 21:52:56 +0100
> # base_revision_id: lekktu@gmail.com-20091229182933-172o63gm6ve7s3gi
> # 
> # Begin patch
> === modified file 'lisp/simple.el'
> --- lisp/simple.el	2009-12-12 17:01:03 +0000
> +++ lisp/simple.el	2009-12-31 20:52:48 +0000
> @@ -768,10 +768,14 @@
>         (constrain-to-field nil orig-pos)))))
 
>  (defun just-one-space (&optional n)
> -  "Delete all spaces and tabs around point, leaving one space (or N spaces)."
> +  "Delete all spaces and tabs around point, leaving one space (or
> +N spaces).  If N is negative, deletes carriage return and
> +linefeed characters as well."
>    (interactive "*p")
> -  (let ((orig-pos (point)))
> -    (skip-chars-backward " \t")
> +  (let ((orig-pos (point))
> +        (skip-characters (if (< n 0) " \t\n\r" " \t"))
> +        (n (abs n)))
> +    (skip-chars-backward skip-characters)
>      (constrain-to-field nil orig-pos)
>      (dotimes (i (or n 1))
>        (if (= (following-char) ?\s)
> @@ -780,7 +784,7 @@
>      (delete-region
>       (point)
>       (progn
> -       (skip-chars-forward " \t")
> +       (skip-chars-forward skip-characters)
>         (constrain-to-field nil orig-pos t)))))
>  \f
>  (defun beginning-of-buffer (&optional arg)

> # Begin bundle
> IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWeooGREAAcRfgEwQUGf/91Yj
> AAS////wUAQGu3aGd5CrKOCUQUzUyMARoaU8mNT1PUmmjDUGgykxJsm0T0immRoZBoDIAADEIJoS
> n6m1M0p6NGo0NqeoNGTQGgykZGpmp6npPUNqAAAAAACSiYhT9JqfqaRsk9TEep5QeoAAA4KNpFA/
> OZVTa9ijbGljtPvOIP2RNudsMnX0gjBNtOp3z5+3zK/0bH6TKKqRHqlsj9ItDy5jRy1LFXD6mnso
> nPu1NM3QdT9keXpHh2z5Vw8Wxxi7AMGDed7wN9RwrxzG2y3c5NOaNiYgomK+Ksx8ZjomErKZd+ix
> s6d6TuIfxInIIUuV+sxXMLHA1mujyEzpBDiUSm+TaVMluhQAzoGwg98QH7wzHsRORBgykZDIRKHV
> TCAn6/r6q5C3xu4TeXP0AumwgRgLVuPb5IWapJVN520O1wtOcIJVGZL7M5B8yFYLEB4QVoB0gwMU
> KBS2gCM15AJmLg+kGpmk2ybWJsmDgJmWBuaMUCuBmg2GJo51BEwZoCnSpaxqg36DjcLhQNbJkAfv
> NOJYLc+mi7kyWR3GqoGFJuDzZiwSecZqpXWaLdlCxrTZqDKPQLZMh7Bc5EMBvHKC3jU6pG+VMAcK
> jmbAPNuH6DJGuZHgdA11oOOrMdMFyDsOCAtRbrhaKiWMwaTuNyo0p0sqMXcUYqikKgTqsfln9hy2
> 3+/IOu7x4czMmV1AEPOPhK9WK9ZVjUVj0OvBo/FE3ODRZWZR18i5Uh1CENx18LwtEfLtNlfcBO5Z
> agxJIcdLhpUqCWXPgXGo3Z3YG6wgL9W8VBJ5gxXbKnsCD3DOZIi0ItoLBdos01BNvdwK9caaEpc3
> sa+sSedWQ2S3E7C2e10ZyPsJeiSZ7k54dFzb4bHK4I8LmcYsaIJl211EzNUAzqa6hU1VQCidfvUE
> E0Jphisnww78czKVzkStxaiorbbclDfqYtcClNKD0a79+WQnAwvcxLScwHluISHLy7YKdM1aQyAp
> IizF9CMbswvZU3aDBaxVvmki80UqWMf6nFmSR+t5CsQvR5SmzqHOhnS8l33aIBEhCMIeEhYBO6Eh
> Wj2cYaZ0WrvFoUOByZuEMaEAa0Jrkhh0HOQ1/TEOH91toI5k7yyBG81nfiNKXzkJHHU0Xf2K1QkT
> DQ5sqAQFAZj10AE+ZaAiEijw6preqs9qVpsBUhXRnQWRBlSpZMmyfxckUNvFMFWtIwKdLHCVtUqe
> Xadlt25OdHAgDmwwRCu4MHzrxqBjsfKgmAgpyQFE97s2yYgQhyNNkajnhx8FeA+3oCFh1qUVQtrV
> 4HJNlpojk7v6C6U3w7AHkO67TbgGh8QLwHPsOHIXx2FDjz8QOuykrYM/txeg8zQ5Y4AaQapkFNTa
> XG6YMgBFgf/i7kinChIdRQMiIA==




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

* Re: Patch to change just-one-space
  2010-11-22 22:16         ` Stefan Monnier
@ 2010-11-23  8:29           ` Tassilo Horn
  2010-12-06 18:22             ` Stefan Monnier
  0 siblings, 1 reply; 33+ messages in thread
From: Tassilo Horn @ 2010-11-23  8:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Daniel Colascione, Deniz Dogan, xahlee, Emacs-Devel devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> Attached is a bzr bundle which does this. If the user passes the
>> argument -N, it will remove any whitespace characters (spaces, tabs,
>> carriage returns, newlines) and leave N spaces. Unfortunately I
>> couldn't think of a good way to make e.g. "M-- M-0 M-SPC" leave 0
>> spaces.
>
> Any objection to such a change?  Removing newlines sounds OK to me, but
> I don't use just-one-space, so I don't have a good feeling for what
> other useful meaning could be used for a negative argument.

I'd highly appreciate such a change.  The last week I had to paste tons
of Java code into several LaTeX listings and I used `just-one-space' and
`kill-line' gazillions of times to reformat it.

And since C-u -1 M-SPC for any negative number is equivalent to C-u 0
M-SPC, I don't think it won't have big impact, at least not in
interactive usage.  And inside the emacs code base, there is only one
call to `just-one-space' with an argument (emulation/cua-rect.el), but
that uses an explitit arg of 0.

Bye,
Tassilo



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

* Re: Patch to change just-one-space
  2010-11-23  8:29           ` Tassilo Horn
@ 2010-12-06 18:22             ` Stefan Monnier
  2010-12-07  0:34               ` Chong Yidong
  2010-12-07  9:43               ` Tassilo Horn
  0 siblings, 2 replies; 33+ messages in thread
From: Stefan Monnier @ 2010-12-06 18:22 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Daniel Colascione, Deniz Dogan, xahlee, Emacs-Devel devel

>>> Attached is a bzr bundle which does this. If the user passes the
>>> argument -N, it will remove any whitespace characters (spaces, tabs,
>>> carriage returns, newlines) and leave N spaces. Unfortunately I
>>> couldn't think of a good way to make e.g. "M-- M-0 M-SPC" leave 0
>>> spaces.
>> 
>> Any objection to such a change?  Removing newlines sounds OK to me, but
>> I don't use just-one-space, so I don't have a good feeling for what
>> other useful meaning could be used for a negative argument.

I saw no objections, so I installed it on the trunk.
Thank you Deniz,


        Stefan



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

* Re: Patch to change just-one-space
  2010-12-06 18:22             ` Stefan Monnier
@ 2010-12-07  0:34               ` Chong Yidong
  2010-12-07  9:43               ` Tassilo Horn
  1 sibling, 0 replies; 33+ messages in thread
From: Chong Yidong @ 2010-12-07  0:34 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: xahlee, Tassilo Horn, Emacs-Devel devel, Daniel Colascione,
	Deniz Dogan

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> Any objection to such a change?  Removing newlines sounds OK to me, but
>>> I don't use just-one-space, so I don't have a good feeling for what
>>> other useful meaning could be used for a negative argument.
>
> I saw no objections, so I installed it on the trunk.
> Thank you Deniz,

I think this needs a NEWS entry.



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

* Re: Patch to change just-one-space
  2010-12-06 18:22             ` Stefan Monnier
  2010-12-07  0:34               ` Chong Yidong
@ 2010-12-07  9:43               ` Tassilo Horn
  2010-12-07 19:45                 ` Tassilo Horn
  1 sibling, 1 reply; 33+ messages in thread
From: Tassilo Horn @ 2010-12-07  9:43 UTC (permalink / raw)
  To: emacs-devel; +Cc: xahlee, Daniel Colascione, Stefan Monnier, Deniz Dogan

On Monday 06 December 2010 19:22:04 Stefan Monnier wrote:

Hi Stefan,

> >>> Attached is a bzr bundle which does this. If the user passes the
> >>> argument -N, it will remove any whitespace characters (spaces, tabs,
> >>> carriage returns, newlines) and leave N spaces. Unfortunately I
> >>> couldn't think of a good way to make e.g. "M-- M-0 M-SPC" leave 0
> >>> spaces.
> >> 
> >> Any objection to such a change?  Removing newlines sounds OK to me,
> >> but I don't use just-one-space, so I don't have a good feeling for
> >> what other useful meaning could be used for a negative argument.
> 
> I saw no objections, so I installed it on the trunk.

There's a problem with your change.  When you call `just-one-space' from
lisp without explicit argument and thus n is nil, you get an error,
because the function expects it to be a number.  So something like

  (setq n (or n 1))

seems to be needed.

Bye,
Tassilo



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

* Re: Patch to change just-one-space
  2010-12-07  9:43               ` Tassilo Horn
@ 2010-12-07 19:45                 ` Tassilo Horn
  2010-12-09  3:57                   ` Stefan Monnier
  0 siblings, 1 reply; 33+ messages in thread
From: Tassilo Horn @ 2010-12-07 19:45 UTC (permalink / raw)
  To: emacs-devel; +Cc: xahlee, Stefan Monnier, Deniz Dogan

Tassilo Horn <tassilo@member.fsf.org> writes:

>> >> Any objection to such a change?  Removing newlines sounds OK to
>> >> me, but I don't use just-one-space, so I don't have a good feeling
>> >> for what other useful meaning could be used for a negative
>> >> argument.
>> 
>> I saw no objections, so I installed it on the trunk.
>
> There's a problem with your change.  When you call `just-one-space' from
> lisp without explicit argument and thus n is nil, you get an error,
> because the function expects it to be a number.

I've fixed it on the trunk.

Bye,
Tassilo



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

* Re: Patch to change just-one-space
  2010-12-07 19:45                 ` Tassilo Horn
@ 2010-12-09  3:57                   ` Stefan Monnier
  0 siblings, 0 replies; 33+ messages in thread
From: Stefan Monnier @ 2010-12-09  3:57 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Deniz Dogan, xahlee, emacs-devel

>>> I saw no objections, so I installed it on the trunk.
>> 
>> There's a problem with your change.  When you call `just-one-space' from
>> lisp without explicit argument and thus n is nil, you get an error,
>> because the function expects it to be a number.

> I've fixed it on the trunk.

Thank you,


        Stefan



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

end of thread, other threads:[~2010-12-09  3:57 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-13 20:37 Patch to change just-one-space Deniz Dogan
2009-08-13 23:12 ` Xah Lee
2009-08-13 23:30   ` Deniz Dogan
2009-08-13 23:35     ` Daniel Colascione
2009-08-13 23:37       ` Deniz Dogan
2009-08-14  0:51         ` Robert J. Chassell
2009-08-14  0:58           ` Deniz Dogan
2009-08-14 10:37           ` Teemu Likonen
2009-12-31 20:55       ` Deniz Dogan
2010-11-22 20:35         ` Deniz Dogan
2010-11-22 22:16         ` Stefan Monnier
2010-11-23  8:29           ` Tassilo Horn
2010-12-06 18:22             ` Stefan Monnier
2010-12-07  0:34               ` Chong Yidong
2010-12-07  9:43               ` Tassilo Horn
2010-12-07 19:45                 ` Tassilo Horn
2010-12-09  3:57                   ` Stefan Monnier
2009-08-14  2:24     ` Xah Lee
2009-08-14  6:53       ` Deniz Dogan
2009-08-14 15:26         ` capitalize-dwim (was: Patch to change just-one-space) Stefan Monnier
2009-08-14 15:36           ` Xah Lee
2009-08-14 16:33             ` capitalize-dwim joakim
2009-08-15  2:31               ` capitalize-dwim Richard Stallman
2009-08-14  8:05       ` Patch to change just-one-space David Kastrup
2009-08-13 23:19 ` Juri Linkov
2009-08-13 23:33   ` Deniz Dogan
2009-08-14  2:10     ` Stephen J. Turnbull
2009-08-14  6:59       ` Deniz Dogan
2009-08-14 12:19         ` Andreas Roehler
2009-08-14 17:10         ` Stephen J. Turnbull
2009-08-14 15:12       ` Stefan Monnier
2009-08-14 15:16         ` Lennart Borgman
2009-08-14  1:14 ` Miles Bader

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).