tbray@mprvaxa.UUCP (Tim Bray) (02/17/86)
(defun buffer-stats () "vi-style lines/chars" (interactive) (let ((chars (buffer-size))) (if (= chars 0) (message "%s: 0 lines, 0 characters" (buffer-name)) (message "%s: %d lines, %d characters" (buffer-name) (count-lines 1 chars) chars)))) (set 'find-file-hook 'buffer-stats) ;;;look like vi (define-key ctl-x-map "l" 'buffer-stats)
christer@kuling.UUCP (Christer Johansson) (02/21/86)
In <695@mprvaxa.UUCP> of Tue, 18-Feb-86 05:35:17 GMT tbray@mprvaxa writes: >(defun buffer-stats () > ... > (count-lines 1 chars) This is wrong. As the first character of the buffer is character one, the last must be character (1+ (buffer-size)). The code should be: (count-lines 1 (1+ chars)) When the empty buffer doesn't need special handling, the following is unnecessary > (if (= chars 0) > (message "%s: 0 lines, 0 characters" (buffer-name)) Changing find-file-hook in a load-file can probably lead to some confusion if it was set before. It's probably best to let the user do that himself. -- SMail: Christer Johansson UUCP: {seismo,seismo!mcvax}!enea!kuling!christer OR Sernandersv. 9:136 christer@kuling.UUCP S-752 63 Uppsala Phone: Int. +46 - 18 46 31 54 SWEDEN Nat. 018 - 46 31 54