[implementations-list] The "{Saved, Deleted} N characters" messages gone with `yy'/`dd'
Štěpán Němec
stepnem at gmail.com
Wed Apr 14 23:40:18 CEST 2010
On Wed, Apr 14, 2010 at 06:14:29PM +0000, Vegard Øye wrote:
> (Any tips on making that function shorter? :)
(defun vimpulse-operator-message
(template &optional beg end length type)
"Echo a message like \"Deleted 2 characters\".
TEMPLATE is a string like \"Deleted <N>\", where <N>
is substituted with the amount of characters or lines.
BEG and END are the range of text. If you specify LENGTH,
they are ignored.
This function respects `viper-change-notification-threshold'."
(let* ((beg (or beg (vimpulse-visual-beginning) 1))
(end (or end (vimpulse-visual-end) 1))
(type (or type vimpulse-this-motion-type))
(length (case type
(block (* (or vimpulse-visual-width 1)
(or vimpulse-visual-height 1)))
(line (or length (count-lines beg end)))
(t (or length (abs (- end beg))))))
(template (replace-regexp-in-string
"<N>"
(apply 'format
(append
(if (eq type 'block)
`("%sx%s character%s"
,(or vimpulse-visual-height 1)
,(or vimpulse-visual-width 1))
`(,(concat "%s " (if (eq type 'line)
"line"
"character") "%s")
,length))
(list (if (/= 1 (abs length)) "s" ""))))
template)))
(when (and (< viper-change-notification-threshold length)
(not (viper-is-in-minibuffer)))
(message template))))
http://tinyurl.com/ycxdzml
More information about the implementations-list
mailing list