unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Gian Fontanilla <prvteprts@yahoo.com>
To: Josh <josh@foxtail.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: Patch for delete-indentation in simple.el
Date: Fri, 23 Aug 2013 20:27:14 -0700 (PDT)	[thread overview]
Message-ID: <1377314834.52309.YahooMailBasic@web163403.mail.gq1.yahoo.com> (raw)

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

Thanks Josh, I was already aware of that thread :)

Stefan, attached is a new patch with your suggestions included.

Regards,
Gian

[-- Attachment #2: Description --]
[-- Type: application/octet-stream, Size: 580 bytes --]

Based on Stefan's recommendations, I re-did the work on
`delete-indentation'.

The function accepts two new optional arguments START and END. When
these are not nil, the function joins all the lines in the region
defined by those two arguments.

When invoked interactively and the region is active, the function
joins all the lines in the region.

The universal argument also works when invoking the function as a
command. For example, C-u 2 M-^ joins the current line and the
previous 2 lines into a single line.

- Gian Fontanilla  <prvteprts@yahoo.com> Sat Aug 24 11:01:29 2013

[-- Attachment #3: ChangeLog --]
[-- Type: application/octet-stream, Size: 158 bytes --]

2013-08-24  Gian Fontanilla  <prvteprts@yahoo.com>

	* simple.el (delete-indentation): Work with new optional
	arguments, the universal argument, and region.

[-- Attachment #4: Patch --]
[-- Type: application/octet-stream, Size: 3443 bytes --]

=== modified file 'lisp/ChangeLog'
*** lisp/ChangeLog	2013-08-24 02:53:43 +0000
--- lisp/ChangeLog	2013-08-24 02:55:33 +0000
***************
*** 1,8 ****
- 2013-08-24  Gian Fontanilla  <prvteprts@yahoo.com>
- 
- 	* simple.el (delete-indentation): Work with new optional
- 	arguments, the universal argument, and region.
- 
  2013-08-23  Glenn Morris  <rgm@gnu.org>
  
  	* files.el (auto-mode-alist): Use sh-mode for .bash_history.
--- 1,3 ----

=== modified file 'lisp/simple.el'
*** lisp/simple.el	2013-08-24 02:53:43 +0000
--- lisp/simple.el	2013-08-24 02:55:33 +0000
*************** When called from Lisp code, ARG may be a
*** 479,537 ****
      (indent-to col 0)
      (goto-char pos)))
  
! (defun delete-indentation (&optional arg start end)
    "Join this line to previous and fix up whitespace at join.
! If there is a fill prefix, delete it from the beginning of this
! line.
! 
! Join this line to ARG number of previous lines when non-nil, or
! through the `universal-argument' when invoking this function
! interactively. ARG is ignored if START and END are non-nil.
! 
! When invoked interactively and region is active, join all the
! lines in the region. For example, operating on an active region
! such as:
! 
!     L1  one
!     L2  two
!     L3  three
!     L4  four
!     L5  five
! 
! joins lines 1-5 into a single line:
! 
!     L1  one two three four five
! 
! Similarly, join all lines in the region defined by positions
! START and END when non-nil."
!   (interactive
!    (if (use-region-p)
!        (list nil (region-beginning) (region-end))
!      (list (prefix-numeric-value current-prefix-arg))))
!   ;; If not invoked interactively, check arguments
!   (cond ((and start end)
! 	 (progn
! 	   (move-end-of-line 1)
! 	   (setq arg (1- (count-lines (min start end)
! 				      (goto-char (max start end)))))))
! 	((not arg) (setq arg 1)))
!   ;; Start the deletion
!   (while (and (not (bobp))
! 	      (and (> arg 0) (setq arg (1- arg))))
!     (beginning-of-line)
!     (if (eq (preceding-char) ?\n)
!   	(progn
!   	  (delete-region (point) (1- (point)))
!   	  ;; If the second line started with the fill prefix,
!   	  ;; delete the prefix.
!   	  (if (and fill-prefix
!   		   (<= (+ (point) (length fill-prefix)) (point-max))
!   		   (string= fill-prefix
!   			    (buffer-substring (point)
!   					      (+ (point) (length fill-prefix)))))
!   	      (delete-region (point) (+ (point) (length fill-prefix))))
!   	  (fixup-whitespace))))
!   t)
  
  (defalias 'join-line #'delete-indentation) ; easier to find
  
--- 479,503 ----
      (indent-to col 0)
      (goto-char pos)))
  
! (defun delete-indentation (&optional arg)
    "Join this line to previous and fix up whitespace at join.
! If there is a fill prefix, delete it from the beginning of this line.
! With argument, join this line to following line."
!   (interactive "*P")
!   (beginning-of-line)
!   (if arg (forward-line 1))
!   (if (eq (preceding-char) ?\n)
!       (progn
! 	(delete-region (point) (1- (point)))
! 	;; If the second line started with the fill prefix,
! 	;; delete the prefix.
! 	(if (and fill-prefix
! 		 (<= (+ (point) (length fill-prefix)) (point-max))
! 		 (string= fill-prefix
! 			  (buffer-substring (point)
! 					    (+ (point) (length fill-prefix)))))
! 	    (delete-region (point) (+ (point) (length fill-prefix))))
! 	(fixup-whitespace))))
  
  (defalias 'join-line #'delete-indentation) ; easier to find
  


             reply	other threads:[~2013-08-24  3:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-24  3:27 Gian Fontanilla [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-08-22  8:59 Patch for delete-indentation in simple.el Gian Fontanilla
2013-08-22 21:03 ` Stefan Monnier
2013-08-23 13:31   ` Gian Fontanilla
2013-08-23 15:50     ` Stefan Monnier
2013-08-23 16:16     ` Josh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377314834.52309.YahooMailBasic@web163403.mail.gq1.yahoo.com \
    --to=prvteprts@yahoo.com \
    --cc=emacs-devel@gnu.org \
    --cc=josh@foxtail.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).