[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Extra info in modeline (tip and questions)
From: |
Decebal |
Subject: |
Re: Extra info in modeline (tip and questions) |
Date: |
Tue, 28 Apr 2009 00:55:32 -0700 (PDT) |
User-agent: |
G2/1.0 |
On 15 apr, 15:14, Nikolaj Schumacher <m...@nschum.de> wrote:
> It probably is. I do it in C myself. But with Lisp you have so many
> parentheses that you lose too much vertical space.
I now also put all the parentheses on the same line. I still need a
little bit to get used to it, but at saves a lot off lines. (Up to
25%.)
> > What I would like is that when I call the function interactively, that
> > instead of returning the value, the value is displayed in the
> > minibuffer. For this I need to know if the function is called
> > interactively. If that is the case, I should do:
> > (message <return-value>)
> > Is there a way to know if the function called interactively?
>
> Well, there is `called-interactively-p', but I would just add another
I changed them to:
(defun buffer-count(expression &optional start end)
(interactive "sExpression: \nr")
(if (equal start end)
(setq start (point-min)
end (point-max))
(setq start (or start (point-min)))
(setq end (or end (point-max))))
(let ((ret-val (how-many expression start end)))
(if (interactive-p)
(message (format "%d" ret-val))
ret-val)))
(defun buffer-count-chars(&optional start end)
(interactive "r")
(let ((ret-val (number-to-string (buffer-count ".\\|\n" start
end))))
(if (interactive-p)
(message ret-val)
ret-val)))
(defun buffer-count-functions(&optional start end)
(interactive "r")
(let ((ret-val (number-to-string (buffer-count "^(defun " start
end))))
(if (interactive-p)
(message ret-val)
ret-val)))
(defun buffer-count-lines(&optional start end)
(interactive "r")
(let ((ret-val (number-to-string
(+ (buffer-count "\n" start end) 1))))
(if (interactive-p)
(message ret-val)
ret-val)))
;;; ### possibillity to give word-type
(defun buffer-count-words(&optional start end)
(interactive "r")
(let ((regexp "\\w+")
(ret-val))
(cond
((equal word-type "lisp")
(setq regexp "[[:word:]\-]+")))
(setq ret-val (number-to-string (buffer-count regexp start
end)))
(if (interactive-p)
(message ret-val)
ret-val)))
The only thing lacking is that when the function is called with C-u
prepended, it should be put at point in the current buffer instead of
in the minibuffer. How would I do that?
Re: Extra info in modeline (tip and questions), Decebal, 2009/04/15