view lisp/delsel.el @ 7291:373b9db3c71c

Removed some keystrokes for obscure toggle commands: C-c C-v C-a, C-c C-v C-p, C-c C-v C-q and C-c C-v C-k. (gnus-uu-decode-and-save-all-unread-articles-and-mark): Fn deleted. (gnus-uu-decode-and-save-all-articles-and-mark): Fn deleted. (gnus-uu-do-sloppy-uudecode): Variable deleted. (gnus-uu-decode-and-save-articles): Rewritten. (gnus-uu-grab-articles, gnus-uu-uustrip-article-as): Rewritten to properly handle multiple encoded files in one gulp. (gnus-uu-uustrip-article-as): Replace spaces in file names with underscores before giving the file to uudecode. (gnus-uu-save-in-digest): Doc fix. (gnus-uu-save-articles, gnus-uu-save-article, gnus-uu-digest-and-forward, gnus-uu-marked-digest-and-forward): Changed old functions and added new functions to digest and forward articles. (gnus-uu-mark-thread): New function to mark a thread for later treatment. (gnus-uu-mark-by-regexp): Changed to add articles instead of clearing before adding. (gnus-uu-check-for-generated-files): First delete files, then directories. (gnus-uu-edit-begin-line, gnus-uu-decode-and-show-in-buffer): Select the current article before starting work. (gnus-uu-decode-and-view-all-unread-articles) (gnus-uu-decode-and-view-all-articles): Two new functions for decoding and viewing all (unread) articles in a newsgroup. (gnus-uu-view-directory, gnus-uu-unpack-archives, gnus-uu-treat-archive): gnus-uu will now treat archives in archives (etc) properly when viewing. (gnus-uu-threaded-multi-decode-and-save, gnus-uu-threaded-multi-decode-and-view): New interactive functions for decoding/saving threads. Bound to `C-c C-v C-j'. (gnus-uu-save-article): Added RFC1153-compliant digest saving. (gnus-uu-initialize): Does some checks and expands relative temp dir names. (gnus-uu-decode-and-show-in-buffer) (gnus-uu-decode-and-strip, gnus-uu-grab-articles) (gnus-uu-decode-and-view-or-save): Allow multiple encoded files to be decoded (and viewed) in one fell swoop. (gnus-uu-work-dir): New variable. (gnus-uu-view-file): Changed to work with metamail. (gnus-uu-get-action, gnus-uu-toggle-view-with-metamail): New functions. (gnus-uu-ext-to-mime, gnus-uu-view-with-metamail): New variables. (gnus-uu-ctl-map): Add C-a binding. (gnus-uu-summary-next-subject): Ensures that the next unread article is moved to. (gnus-uu-default-interactive-view-rules-end): New variable to provide a "catch-all" when using interactive mode. (gnus-uu-get-action): Changed viewing rules in interactive mode. (gnus-uu-uustrip-article-as): Disabled case-fold-search and changed gnus-uu-body-line to be more restrictive. (gnus-uu-multi-decode-and-view-or-save, gnus-uu-uustrip-article-as): Changed hard returns to \r. (gnus-uu-post-reply-mode): New mode for sending encoded files. (gnus-uu-post-news, gnus-uu-post-insert-binary-in-article) (gnus-uu-post-encode-uuencode, gnus-uu-post-encode-mime-uuencode) (gnus-uu-post-encode-mime, gnus-uu-post-make-mime) (gnus-uu-post-encode-file, gnus-uu-post-news-inews) (gnus-uu-post-insert-binary, gnus-uu-post-encoded): New functions. (gnus-uu-post-encode-method, gnus-uu-post-include-before-composing) (gnus-uu-post-threaded, gnus-uu-post-binary-separator): New variables.
author Richard M. Stallman <rms@gnu.org>
date Tue, 03 May 1994 06:05:48 +0000
parents 902c32c709f7
children b589ba0d8960
line wrap: on
line source

;;; delsel.el --- delete selection if you insert

;;; Copyright (C) 1992 Free Software Foundation, Inc.

;; Author: Matthieu Devin <devin@lucid.com>
;; Created: 14 Jul 92
;; Last change  18-Feb-93, devin.

;;; This file is part of GNU Emacs.

;;; GNU Emacs 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 2, or (at your option)
;;; any later version.

;;; GNU Emacs 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.

;;; You should have received a copy of the GNU General Public License
;;; along with GNU Emacs; see the file COPYING.  If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Commentary:

;;; This file makes the active region be pending delete, meaning that
;;; text inserted while the region is active will replace the region contents.
;;; This is a popular behavior of personal computers text editors.

;;; Code:

(defvar delete-selection-mode t
  "*Non-nil means Delete Selection mode is enabled.
In Delete Selection mode, when a region is highlighted,
insertion commands first delete the region and then insert.")

(defun delete-active-region (&optional killp)
  (if killp
      (kill-region (point) (mark))
    (delete-region (point) (mark)))
  (setq mark-active nil)
  (run-hooks 'deactivate-mark-hook)
  t)

(defun delete-selection-pre-hook ()
  (if (and delete-selection-mode
	   (not buffer-read-only)
	   transient-mark-mode mark-active)
      (let ((type (and (symbolp this-command)
		       (get this-command 'delete-selection))))
	(cond ((eq type 'kill)
	       (delete-active-region t))
	      ((eq type 'supersede)
	       (if (delete-active-region nil)
		   (setq this-command '(lambda () (interactive)))))
	      (type
	       (delete-active-region nil))))))

(add-hook 'pre-command-hook 'delete-selection-pre-hook)

(put 'self-insert-command 'delete-selection t)

(put 'yank 'delete-selection t)
(put 'insert-register 'delete-selection t)

(put 'delete-backward-char 'delete-selection 'supersede)
(put 'backward-delete-char-untabify 'delete-selection 'supersede)
(put 'delete-char 'delete-selection 'supersede)

(put 'newline-and-indent 'delete-selection 't)
(put 'newline 'delete-selection t)
(put 'open-line 'delete-selection t)

;;;###autoload
(defalias 'pending-delete-mode 'delete-selection-mode)
;;;###autoload
(defun delete-selection-mode (arg)
  "Toggle Delete Selection mode.
When ON, typed text replaces the selection if the selection is active.
When OFF, typed text is just inserted at point."
  (interactive "P")
  (setq delete-selection-mode
	(if (null arg) (not delete-selection-mode)
	  (> (prefix-numeric-value arg) 0)))
  (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line.

;; This is very useful for cancelling a selection in the minibuffer without 
;; aborting the minibuffer.
(defun minibuffer-keyboard-quit ()
  "Abort recursive edit.
In Delete Selection mode mode, if the mark is active, just deactivate it;
then it takes a second C-g to abort the minibuffer."
  (interactive)
  (if (and delete-selection-mode transient-mark-mode mark-active)
      (setq deactivate-mark t)
    (abort-recursive-edit)))

(define-key minibuffer-local-map "\C-g" 'minibuffer-keyboard-quit) 
(define-key minibuffer-local-ns-map "\C-g" 'minibuffer-keyboard-quit) 
(define-key minibuffer-local-completion-map "\C-g" 'minibuffer-keyboard-quit) 
(define-key minibuffer-local-must-match-map "\C-g" 'minibuffer-keyboard-quit) 
(define-key minibuffer-local-isearch-map "\C-g" 'minibuffer-keyboard-quit) 

(provide 'delsel)

;;; delsel.el ends here