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

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