all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ian Zimmerman <itz@buug.org>
To: help-gnu-emacs@gnu.org
Subject: code: deleterious mode [Was: yank-pop problem]
Date: Fri, 7 Aug 2015 11:49:36 -0700	[thread overview]
Message-ID: <20150807184750.8448.34B15BAC@ahiker.mooo.com> (raw)
In-Reply-To: <20150807031208.1255.1CEF4BA2@ahiker.mooo.com>

This thread gave me an idea :-)

Constructive criticism most welcome!

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

(defmacro deleterious-def (thing)
  (let ((sthing (symbol-name thing)))
  `(defun ,(intern (concat "deleterious-delete-" sthing)) (n)
     ,(concat
       "Delete a " sthing
       " without adding to the kill ring.
Numeric prefix arg means delete that many " sthing "s.
Negative arg means delete backward.")
     (interactive "p")
     (let ((bound
            (save-excursion
              (forward-thing (quote ,thing) n)
              (point))))
       (if (< (point) bound) (delete-region (point) bound)
         (delete-region bound (point)))))))

(deleterious-def line)
(deleterious-def sentence)
(deleterious-def sexp)
(deleterious-def word)

(defconst deleterious-mode-map
  (let ((k (make-sparse-keymap)))
    (define-key k [remap kill-region] 'delete-region)
    (define-key k [remap kill-line] 'deleterious-delete-line)
    (define-key k [remap kill-sentence] 'deleterious-delete-sentence)
    (define-key k [remap kill-sexp] 'deleterious-delete-sexp)
    (define-key k [remap kill-word] 'deleterious-delete-word)
    k)
  "Keymap to use in Deleterious minor mode.")

;;;###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)

\f
;; 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.




  reply	other threads:[~2015-08-07 18:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06  7:38 yank-pop problem Frederik Eaton
2015-08-06 23:49 ` Frederik Eaton
2015-08-07  3:15   ` Ian Zimmerman
2015-08-07 18:49     ` Ian Zimmerman [this message]
2015-08-07 22:06       ` code: deleterious mode Ian Zimmerman
2015-08-10  5:31         ` Frederik Eaton
2021-05-26 22:53 ` bug#21199: yank-pop problem Lars Ingebrigtsen

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

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

  git send-email \
    --in-reply-to=20150807184750.8448.34B15BAC@ahiker.mooo.com \
    --to=itz@buug.org \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.