[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: code: deleterious mode
From: |
Ian Zimmerman |
Subject: |
Re: code: deleterious mode |
Date: |
Fri, 7 Aug 2015 15:06:25 -0700 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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.