From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Zimmerman Newsgroups: gmane.emacs.help Subject: Re: code: deleterious mode Date: Fri, 7 Aug 2015 15:06:25 -0700 Message-ID: <20150807220512.10087.2415895F@ahiker.mooo.com> References: <20150806073831.GA4560@ofb.net> <20150806234942.GA6355@ofb.net> <20150807031208.1255.1CEF4BA2@ahiker.mooo.com> <20150807184750.8448.34B15BAC@ahiker.mooo.com> Reply-To: help-gnu-emacs@gnu.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1438985201 15336 80.91.229.3 (7 Aug 2015 22:06:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Aug 2015 22:06:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 08 00:06:41 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZNpmh-0004nA-AP for geh-help-gnu-emacs@m.gmane.org; Sat, 08 Aug 2015 00:06:39 +0200 Original-Received: from localhost ([::1]:51346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNpmg-0006ky-CW for geh-help-gnu-emacs@m.gmane.org; Fri, 07 Aug 2015 18:06:38 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNpmX-0006ir-0T for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 18:06:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNpmW-0004K2-1c for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 18:06:28 -0400 Original-Received: from disorder-1-pt.tunnel.tserv3.fmt2.ipv6.he.net ([2001:470:1f04:51a::2]:35583 helo=acedia.primate.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNpmV-0004Jm-P3 for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 18:06:27 -0400 Original-Received: from acedia.primate.net (localhost [127.0.0.1]) by acedia.primate.net (8.14.9/8.14.9/Debian-2) with ESMTP id t77M6Qaj009759 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 7 Aug 2015 15:06:26 -0700 Original-Received: (from itz@localhost) by acedia.primate.net (8.14.9/8.14.9/Submit) id t77M6P3x009754 for help-gnu-emacs@gnu.org; Fri, 7 Aug 2015 15:06:25 -0700 X-Authentication-Warning: acedia.primate.net: itz set sender to itz@buug.org using -f Original-Received: from itz by ahiker.mooo.com with local (Exim 4.80) (envelope-from ) id 1ZNpmT-0002dh-C2 for help-gnu-emacs@gnu.org; Fri, 07 Aug 2015 15:06:25 -0700 Content-Disposition: inline In-Reply-To: <20150807184750.8448.34B15BAC@ahiker.mooo.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:1f04:51a::2 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106329 Archived-At: Now even denser, and with backward deletions too. Probably final. ;;; deleterious.el --- minor move to delete things instead of killing them ;; Copyright (C) Ian Zimmerman 2015 ;; Terms: GNU General Public License, Version 2 (require 'thingatpt) (defconst deleterious-mode-map (let ((k (make-sparse-keymap))) (define-key k [remap kill-region] 'delete-region) k) "Keymap to use in Deleterious minor mode.") (defsubst deleterious-del (thing n) (let ((bound (save-excursion (forward-thing thing n) (point)))) (if (< (point) bound) (delete-region (point) bound) (delete-region bound (point))))) (defmacro deleterious-def (thing) (let* ((sth (symbol-name thing)) (ndoc (concat "Numeric prefix arg means delete that many " sth "s.\n")) (delthing (intern (concat "deleterious-delete-" sth))) (bdelthing (intern (concat "deleterious-backward-delete-" sth))) (kthing (intern (concat "kill-" sth))) (bkthing (intern (concat "backward-kill-" sth)))) `(let (fdelthing fbdelthing) (setq fdelthing (fset (quote ,delthing) (lambda (n) (interactive "p") (deleterious-del (quote ,thing) n)))) (put (quote ,delthing) 'function-documentation (concat "Delete a " ,sth " without adding to the kill ring.\n" ,ndoc "Negative arg means delete backward.")) (define-key deleterious-mode-map [remap ,kthing] fdelthing) (setq fbdelthing (fset (quote ,bdelthing) (lambda (n) (interactive "p") (deleterious-del (quote ,thing) (- n))))) (put (quote ,bdelthing) 'function-documentation (concat "Delete a " ,sth " backward without adding to the kill ring.\n" ,ndoc "Negative arg means delete forward.")) (define-key deleterious-mode-map [remap ,bkthing] fbdelthing)))) (deleterious-def line) (deleterious-def sentence) (deleterious-def sexp) (deleterious-def word) ;;;###autoload (define-minor-mode deleterious-mode "Set or toggle Deleterious minor mode. It deletes instead of killing. This global minor mode rebinds a few keys to commands which remove bits of text but *do not* put them on the kill ring. It is useful for repetitive tasks involving multiple yanks of the same string; the string you yank will not get pushed back in the kill ring by new additions." :global t :init-value nil :lighter " Del" :keymap deleterious-mode-map) (provide 'deleterious) ;; Local Variables: ;; End: ;;; deleterious.el ends here -- Please *no* private copies of mailing list or newsgroup messages. Rule 420: All persons more than eight miles high to leave the court.