🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98674

Re: Enabling a command forever - too easy

#98674
From: Stephen Gildea
Date: Fri, 26 Apr 1991 15:09
62 lines
2978 bytes
    From: kyle@uunet.uu.net (Kyle Jones)
    Subject: Re: Enabling a command forever - too easy

    ...
    
    I've pretty handy with Emacs and even I wouldn't mind having
    something like vi's "set report" facility so you would get a
    message if x number of lines are deleted.  This would be more
    useful than disabling the command outright.
    

Here something I wrote for a friend with the same wishes.  It
announces in the echo area when text has been cut or killed.  You
might want to enhance it further to only report if the character or
line count is above a certain threshhold.  And perhaps it should
print the number of lines spanned by the action.

 < Stephen
   MIT X Consortium


;;; feedback.el

;;; Kill region and save region, but with a message in the minibuffer
;;; telling you what happened.  Inspired by Eric Brosius.
;;; Written by Stephen Gildea <gildea@lcs.mit.edu> Sept 1988.

(defun save-region-with-feedback (beg end)
  "Save the region as if killed, but don't kill it.
Display a message saying what we have done."
  (interactive "r")
  (feedback-on-region "Saving region:" beg end)
  (copy-region-as-kill beg end))

(defun kill-region-with-feedback (beg end)
  "Kill between point and mark.
The text is deleted but saved in the kill ring.
Display a message saying what we have done."
  (interactive "r")
  (feedback-on-region "Killing region:" beg end)
  (kill-region beg end))
  
(defun feedback-on-region (msg beg end)
  (if (<= (- end beg) 50)
      (message "%s \"%s\"" msg
	       (string-visible-tabs (buffer-substring beg end)))
    (message "%s \"%s  ...  %s\"" msg
	     (string-visible-tabs (buffer-substring beg (+ beg 25)))
	     (string-visible-tabs (buffer-substring (- end 25) end)))))

(defun string-visible-tabs (string)
  "Returns a string identical to STRING except that all tab characters
have been replaced with the two characters \"^I\""
  (let ((new-string "") tab-pos)
    (while (setq tab-pos (string-match "\t" string))
      (setq new-string (concat new-string (substring string 0 tab-pos) "^I"))
      (setq string (substring string (match-end 0))))
    (concat new-string string)))

(global-set-key "\ew" 'save-region-with-feedback)
(global-set-key "\C-x\C-k" 'kill-region-with-feedback)
Technical Details
Message-ID: <9104261509.AA01506@alex.lcs.mit.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!unreplyable!garbage
References: <130314@uunet.UU.NET>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,f0c2779800ac87fa
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-04-27 02:01:10 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!unreplyable!garbage
From: gildea@EXPO.LCS.MIT.EDU (Stephen Gildea)
Newsgroups: gnu.emacs.bug
Subject: Re: Enabling a command forever - too easy
Message-ID: <9104261509.AA01506@alex.lcs.mit.edu>
Date: 26 Apr 91 15:09:39 GMT
References: <130314@uunet.UU.NET>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: X Consortium, MIT Laboratory for Computer Science
Lines: 62
Approved: bug-gnu-emacs@prep.ai.mit.edu