From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: John Wiegley Newsgroups: gmane.emacs.devel Subject: Re: Is it just me, or did 21.3.50 get a whole lot slower? Date: Thu, 02 Jan 2003 22:50:11 -0700 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87u1gqpyss.fsf@alice.dynodns.net> References: <87adpxob2n.fsf@alice.dynodns.net> <200206152147.g5FLlfU10992@aztec.santafe.edu> <87bs5r1cyp.fsf@gnu.org> <87hecud8ef.fsf@alice.dynodns.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1041584551 28010 80.91.224.249 (3 Jan 2003 09:02:31 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 3 Jan 2003 09:02:31 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18UNin-0007He-00 for ; Fri, 03 Jan 2003 10:02:29 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18UNlJ-0006QK-00 for ; Fri, 03 Jan 2003 10:05:06 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18UNgM-0003wU-03 for emacs-devel@quimby.gnus.org; Fri, 03 Jan 2003 03:59:58 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18UKiq-0008HH-00 for emacs-devel@gnu.org; Fri, 03 Jan 2003 00:50:20 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18UKin-0008Gd-00 for emacs-devel@gnu.org; Fri, 03 Jan 2003 00:50:19 -0500 Original-Received: from mail.gci-net.com ([216.183.68.100] helo=gci-net.com) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18UKim-0008EA-00 for emacs-devel@gnu.org; Fri, 03 Jan 2003 00:50:17 -0500 Original-Received: from [216.183.69.135] (HELO aris) by gci-net.com (CommuniGate Pro SMTP 3.5.9) with ESMTP-TLS id 5234399 for emacs-devel@gnu.org; Thu, 02 Jan 2003 22:49:16 -0700 Original-Received: from johnw by aris with local (Exim 3.35 #1 (Debian)) id 18UKih-0000gf-00 for ; Thu, 02 Jan 2003 22:50:11 -0700 Original-To: emacs-devel@gnu.org X-Public-Key: http://pgp5.ai.mit.edu:11371/pks/lookup?op=get&search=0xF40524D0 X-Home-Page: http://www.gci-net.com/users/j/johnw/ In-Reply-To: (Richard Stallman's message of "Thu, 02 Jan 2003 13:38:04 -0500") User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10431 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10431 --=-=-= >>>>> On Thu Jan 2, Richard writes: >> This issue is now closed. I discovered that the implementation of >> "wide-column.el" was the culprit. It was abusing the >> post-command-hook in a way that worked in 21.2, but not in 21.3. >> I have referred the problem to the author. > Can you tell me what the problem is? Maybe I should fix what > broke. I did not take the time to track it down, nor can I just yet. I would recommend talking with the author, as likely he will be interested in fixing it to be compatible with 21.3. His e-mail is: Phillip Lord To reproduce, just load the module in 21.3 and start using it during your regular workday. The slow-down should become apparent. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=wide-column.el Content-Transfer-Encoding: 8bit Content-Description: wide-column.el ;;; wide-column.el --- Calls functions dependant on column position. ;; $Revision: 1.1 $ ;; $Date: 2002/04/11 22:58:32 $ ;; This file is not part of Emacs ;; Copyright (c) 2002 Phillip Lord ;; Author: Phillip Lord ;; Maintainer: Phillip Lord ;; Keywords: minor mode, cursor colour, column width ;; COPYRIGHT NOTICE ;; ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundationl; either version 2 or (at ;; your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Status: ;; ;; Newly released. Use at your own risk, which is of course what the ;; copyright notice says anyway. See issues also. ;; ;; New versions will hidden somewhere at http://www.russet.org.uk ;;; Commentary: ;; ;; This package is designed to run functions depending on the column ;; that the cursor is in. My initial idea with it, is just to have it ;; change the cursor colour, lightening it as you go over the fill ;; column length. ;; ;; The point of this is that monitor sizes have in recent years got ;; plain silly, and its now relatively easy to buy one the size of a ;; small wardrobe. Combined with the other wise wonderful ;; `dabbrev-expand' which makes it feasible to use very explantory, ;; and very long variable, and function names, source code has a habit ;; of becoming stupidly wide. Now of course this wouldn't matter very ;; much, if we all had wide screens. However in recent years, flat ;; screen monitors have become widely prevelant, and these generally ;; have lower resolutions, and smaller screen sizes, unless you are ;; very rich. This raises the nasty possibility of a split therefore ;; in behaviour between those using LCD, and CRT based monitors. ;; Coming, as I do, from the left of the political spectrum, naturally ;; I find such divisiveness worrying. This, therefore, is my ;; contribution to preventing it. ;;; Similar Packages: ;; ;; Sandip Chitale (sandip.chitale@blazesoft.com) highlight-beyond-fill ;;; Installation ;; ;; Place this file in your Emacs load path. Put (require 'wide-column) ;; into your .emacs or equivalent file. This operates as a normal ;; minor mode, so `wide-column-mode' will toggle it on and off. ;; ;; The code was developed on Gnu Emacs. I think it should work on ;; XEmacs using the FSF compatibility packages, but I haven't tried ;; it. ;;; Issues; ;; ;; 1) I'm not sure about the error handling. I think things are ;; working quite well. However if the affector function crashes out, ;; it will appear to the user that wide-column mode is on, but ;; actually, it will be disabled. I can solve this easily, by ;; switching the mode off on errors, but easy-mmode produces ;; mini-buffer messages, which hide my own attempts to provide error ;; reporting. I think this way is better. If a crash happens the ;; system will be inconsistent, but the alternative will be to have ;; the minor-mode switch itself off. ;; ;; 2) The colour list is poor. I would like to improve things here, ;; but I am not sure how. See the comments near the definition of ;; `wide-column-colour-list' ;; ;; 3) Custom support would be good, and no doubt will be added at some ;; time. ;; ;; 4) It's not going to work if people use lots of different default ;; cursor colours. Seems like a daft thing to do to me! Something to ;; work on anyway. ;;; History: ;; ;; $Log: wide-column.el,v $ ;; Revision 1.1 2002/04/11 22:58:32 johnw ;; *** empty log message *** ;; ;; Revision 1.3 2002/04/04 11:52:24 phillord ;; Added date ;; ;; Revision 1.2 2002/04/04 11:45:46 phillord ;; Added documentation ;; ;; Revision 1.1 2002/04/04 11:39:50 phillord ;; Initial checkin ;; ;; (require 'easy-mmode) ;;; Code: ;; Basic variables. Defcustom these later. (defvar wide-column-start-width nil "The column beyond which the `wide-column-affector-function' is called. If this variable is set to nil then the value of `fill-column' is used instead.") (make-variable-buffer-local 'wide-column-start-width) (defvar wide-column-affector-function 'wide-column-warning-colour "This defines the main affector function. This function is called when the cursor is at a position greater than `wide-column-start-width'. If this affector function fails for some reason then errors are reported to the mini-buffer. The system will try to do its best to return things to normal, but obviously this is a programming error somewhere, so there are no guarentees. The affector function must have the following properties:- It should take a single parameter. If this parameter is positive then it is the amount that the cursor position is in excess of the maximum. The function will be called after every command while the cursor is beyond the maximum allowable value, so don't make it too heavy weight, or it will make editing slow. If the parameter is negative, or zero then its still the amount that the cursor is in excess of the maximum (i.e. the cursor is lower than or equal to the maximum). The function will be called with these values however only when moving from over the maximum to below it once, as an optimisation. If the parameter is the symbol `on', then it mean that the function is being called for the first time in this buffer, and it should do what ever is necessary. If the parameter is the symbol `off', then it means that the mode is being switched off, in the current buffer. If the parameter is the symbol `reset' then it means that the cursor has moved out of the old buffer and into a new one, and a reset should happen. Its important to realise here that when this reset happens the `current-buffer' may or may not be using the option `wide-column-mode'. The function only needs to do something therefore, if it affects a global property, like for instance the cursor colour. If it affects a buffer local property, then IT WILL BE IN THE WRONG BUFFER And finally it shouldn't do anything daft, like leaving the current buffer changed, probably it shouldn't move point. Deleting all of the text in excess of the wide column would be amusing, but still perhaps not a good idea.") (make-variable-buffer-local 'wide-column-affector-function) ;;; This section provides the basic functionality of the mode. (defvar wide-column-last-command-over-width-p nil "The last command executed beyond the maximum width.") (make-variable-buffer-local 'wide-column-last-command-over-width-p) (defvar wide-column-buffer-affector-last-called-in nil "The last buffer an affector was called in. This is the last buffer that any `wide-column-affector-function' was called in. This information is recorded so that things can be reset, when the buffer is moved out of.") (defvar wide-column-affector-function-last-called nil "This is the last affector function that was called.") (defun wide-column-post-command-hook-function() "This calls the function specified by `wide-column-affector-function' when the cursor is beyond the column `wide-column-start-width' if it is set, or `fill-column' if it is not. See the documentation of `wide-column-affector-function' for full details." (interactive) (condition-case err (progn (let ((buffer (current-buffer))) (if (not (eq wide-column-buffer-affector-last-called-in buffer)) ;; we have moved out of the a wide column buffer, ;; therefore we need to reset the affector from the last ;; buffer (if wide-column-affector-function-last-called (funcall wide-column-affector-function-last-called 'reset)))) ;; now only actually do anything if wide-column-mode is on (if wide-column-mode (let ((column-position (current-column)) (start-width (or wide-column-start-width fill-column))) (if (> column-position start-width) (progn (wide-column-call-affector) (setq wide-column-last-command-over-width-p t)) (if wide-column-last-command-over-width-p (progn (wide-column-call-affector) (setq wide-column-last-command-over-width-p nil))))))) (error ;; this catches errors in this function, or in the affector ;; function. If I don't do this then emacs just empties ;; post-command-hook, which makes things a pain in the ass to ;; debug, and will affect other packages using this hook (progn ;; Switch the mode off. This will leave the system in an ;; inconsistent state, as the minor mode will still appear to ;; be on. I am not sure what to do with this. I've tried just ;; switching the mode off, but the informative message from ;; easy-mmode covers up the error report. (wide-column-mode-emergency-off) (backtrace) (message "Error from `wide-column-affector-function' caught: %s" (error-message-string err)))))) (defun wide-column-call-affector () "Call the affector with the column position." ;; sing hey diddle dey, for dynamic scoping (funcall wide-column-affector-function (- column-position start-width)) ;; record this stuff so that we can reset correctly. (setq wide-column-affector-function-last-called wide-column-affector-function) (setq wide-column-buffer-affector-last-called-in (current-buffer))) (define-minor-mode wide-column-mode "Toggle wide-column mode. With no argument, this command toggles this mode. Non-null prefix arguments turns on the mode, Null prefix argument turns it off. When wide-column mode is enabled, the function defined in `wide-column-affector-function' is called, when your cursor has gone beyond `wide-column-start-width' if it's set, or `fill-column' it its not. By default the practical upshot of this is that cursor colour changes, when your lines get too long." :group 'wide-column :lighter " wc" (if wide-column-mode (funcall wide-column-affector-function 'on) (funcall wide-column-affector-function 'off))) (easy-mmode-define-global-mode global-wide-column-mode wide-column-mode wide-column-turn-on) ;; switch off when global mode is (add-hook 'global-wide-column-mode-hook 'global-wide-column-hook) (defun global-wide-column-hook() "Help to switch off global mode" (interactive) (if (not global-wide-column-mode) (funcall wide-column-affector-function 'off))) (defun wide-column-turn-on() (wide-column-mode 1)) (defun wide-column-mode-emergency-off() "Get out of `wide-column-mode'. Calling this function disabled this mode totally, and irrespective of whether its actually switched on or not. It's an emergency function, in case of crashes, and should not normally be called. `wide-column-mode-reset' turns it back on again. " (interactive) ;; switch mode off (remove-hook 'post-command-hook 'wide-column-post-command-hook-function)) ;; I can't find any leaving or entering buffer hooks. So I have to use ;; a global post-command hook. I don't really like this, but what can ;; you do? (defun wide-column-mode-reset() "This function resets` wide-column mode' if its been switched off due to errors" (interactive) (add-hook 'post-command-hook 'wide-column-post-command-hook-function)) (wide-column-mode-reset) ;; This is the bit which provides the colour switching code, which is ;; the default behaviour of this package. ;; with faces you can set colours depending on whether the background ;; is dark or light. I don't know how to do this with colour ;; names. Also the colour list that I am using here is fine for me, ;; but its based on my usual cursor colour. What I would really like ;; to do is lighten the colour each time I move further from the ;; fill-column. So it would be nice to be able to get from one colour ;; to the next automatically, without just specifying a list. (defvar wide-column-colour-list '("orange" "yellow" "white")) (setq wide-column-warning-colour-quotient 5) (defvar wide-column-default-cursor-colour (setq wide-column-default-cursor-colour (frame-parameter (selected-frame) 'cursor-color)) "Place to store the default cursor colour.") (defun wide-column-warning-colour(current-excess-column) "Set the cursor colour depending on the column position" ;; first we need to test for a flag condition, mostly to ;; reset or store the current cursor colour. (cond ((or (eq 'reset current-excess-column) (eq 'off current-excess-column)) (set-cursor-color wide-column-default-cursor-colour)) ((eq 'on current-excess-column) nil) ;; now we need to actually do the cursor colour change. Change it ;; back to default. ((>= 0 current-excess-column) (set-cursor-color wide-column-default-cursor-colour)) ;; change it to something else. (t (let* ((max-colour-index (- (length wide-column-colour-list) 1)) (suggested-colour-number (/ current-excess-column wide-column-warning-colour-quotient)) (actual-colour-number (if (> suggested-colour-number max-colour-index) max-colour-index suggested-colour-number))) (set-cursor-color (nth actual-colour-number wide-column-colour-list)))))) ;; Some test code (defun wide-column-warning-colour-test() (interactive) (wide-column-warning-colour (- (current-column) 20))) (defun wide-column-shout-about-affector() (interactive) (setq wide-column-affector-function (lambda(current-excess-column) (message "Wide Column Affector called with column %s" current-excess-column)))) (defun wide-column-restore-default-affector() (interactive) (setq wide-column-affector-function 'wide-column-warning-colour)) ;(default-value wide-column-affector-function))) (provide 'wide-column) ;;; wide-column.el ends here --=-=-= John --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --=-=-=--