back-indent.el
Roland McGrath
mcgrath%paris.Berkeley.EDU at GINGER.BERKELEY.EDU
Sun Dec 10 07:23:14 AEST 1989
Original-posting-by: mcgrath%paris.Berkeley.EDU at GINGER.BERKELEY.EDU (Roland McGrath)
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)
Posting-id: 891209.2025
Posting-number: Volume TEST, Number TEST
Archive-name: back-indent.el
[This is an experimental alt.sources re-posting from the
newsgroup(s) gnu.emacs.bug.
No attempt has been made to edit, clean, modify, or otherwise
change the contents of the original posting, or to contact the
author. Please consider cross-posting all sources postings to
alt.sources as a matter of course.]
[Comments on this service to emv at math.lsa.umich.edu (Edward Vielmetti)]
Here is a new version of back-indent-relative which behaves properly when point
is not at the indentation point (i.e., if there's some non-whitespace text
before point).
;;; Copyright (C) 1989 Roland McGrath
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 1, or (at your option)
;;; any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; A copy of the GNU General Public License can be obtained from this
;;; program's author (send electronic mail to roland at ai.mit.edu) or from
;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
;;; 02139, USA.
;;;
;;; Send bug reports to roland at ai.mit.edu.
;; To use this, byte-compile this file, and then put the following line
;; in your .emacs (or site-init.el, etc.):
;; (autoload 'back-indent-relative "back-indent" "Reverse-indent." t)
(defun back-indent-relative ()
"Move back an indentation level, deleting spaces and tabs.
Indentation levels are defined by the amount of leading whitespace on
the preceding lines. This is essentially the reverse of \\[indent-relative]."
(interactive)
(let* ((start-column (current-indentation))
(indent start-column))
(save-excursion
(while (and (>= indent start-column)
(progn (beginning-of-line)
(re-search-backward "^[^\n]" nil t)))
(setq indent (current-indentation))))
(move-to-column start-column)
(backward-delete-char-untabify (- start-column indent) nil)
))
More information about the Alt.sources
mailing list