nate@mipos3.intel.com (Nate Hess) (06/24/88)
I've found a bug in the center-region function of GNU Emacs. (We're running 18.51 here.) A pseudo-lossage description of how to repeat the bug (after typing emacs -q from the command line): E n t e r SPC p a s s w o r d SPC f o l l o w e d SPC b y SPC < C R > SPC t o SPC e x i t . ESC x c e n t e r - l RET RET RET RET RET RET RET RET RET RET RET b a c k SPC i n SPC 5 RET w o o d s t o c k RET C-r C-q LFD C-q LFD ESC ESC > ESC x c e n t e r - r RET C-h l The 'back in 5' line centers, but the 'woodstock' line doesn't. Here's the new center-region function I wrote that fixes this bug: (defun center-region (from to) "Center each line starting in the region. See center-line for more info." (interactive "r") (if (> from to) (let ((tem to)) (setq to from from tem))) (save-excursion (goto-char from) ; ; Basically, the bug stemmed from the fact that the end of the ; region is fixed at the beginning of the while loop, and characters ; are added to center lines properly, but the variable 'to' ; representing the end of the region does not reflect the new ; effective region each time 'center-line' is called. ; (let (number-of-ws-chars original-number-of-ws-chars) (while (< (point) to) (setq original-number-of-ws-chars (count-indenting-ws-chars)) (center-line) (setq number-of-ws-chars (count-indenting-ws-chars)) (setq to (+ to (- number-of-ws-chars original-number-of-ws-chars))) (forward-line 1)))) ) ;center-region I mailed this into bug-gnu-emacs, but never saw it on the mailing list... If you can see any obvious improvements I could make in the code, drop me a line. Happy Centering, --woodstock -- "How did you get your mind to tilt like your hat?" ...!{decwrl|hplabs!oliveb|pur-ee|qantel|amd}!intelca!mipos3!nate <domainish> : nate@mipos3.intel.com ATT : (408) 765-4309
heins@trwrb.UUCP (Michael T. Heins) (06/25/88)
> ... [a fix to text-mode.el] > > I mailed this into bug-gnu-emacs, but never saw it on the mailing > list... If you can see any obvious improvements I could make in the > code, drop me a line. Well, Nate, thanks for the fix, but when I installed it in my version 18.51, I got a message: Symbol's function definition is void: count-indenting-ws-chars Could you post the missing definitions, please? Thanks. -- ...!hplabs!sdcrdcf!trwrb!heins We are a way for the universe to know itself. -- Carl Sagan
nate@mipos3.intel.com (Nate Hess) (06/27/88)
In article <6938@trwrb.UUCP> heins@trwrb.dsd.trw.com.UUCP (Michael T. Heins) writes: >Well, Nate, thanks for the fix, but when I installed it in my >version 18.51, I got a message: > Symbol's function definition is void: count-indenting-ws-chars >Could you post the missing definitions, please? Thanks. Whoops, sorry about that! Here is the missing function: (defun count-indenting-ws-chars () "Count the number of white space characters starting the current line." (let (bol bot) (beginning-of-line) (setq bol (point)) (back-to-indentation) (setq bot (point)) (- bot bol)) ) ;count-indenting-ws-chars -- "How did you get your mind to tilt like your hat?" ...!{decwrl|hplabs!oliveb|pur-ee|qantel|amd}!intelca!mipos3!nate <domainish> : nate@mipos3.intel.com ATT : (408) 765-4309