From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sullivan Beck Newsgroups: gmane.emacs.bugs Subject: bug#4954: 23.1; Emacs hangs when two run-at-time calls in effect Date: Wed, 18 Nov 2009 10:41:48 -0500 Message-ID: <4B0415BC.9010400@ufl.edu> Reply-To: Sullivan Beck , 4954@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1258583009 12749 80.91.229.12 (18 Nov 2009 22:23:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Nov 2009 22:23:29 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 18 23:23:22 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NAsvk-0007Ny-0c for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 23:23:19 +0100 Original-Received: from localhost ([127.0.0.1]:33925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAsvj-0004IA-9N for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Nov 2009 17:23:15 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAn45-0003lw-Ff for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 11:07:29 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAn40-0003fg-Ot for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 11:07:28 -0500 Original-Received: from [199.232.76.173] (port=52836 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAn40-0003fV-2B for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 11:07:24 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:40053) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NAn3z-0001Ys-AQ for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 11:07:23 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAIG7K3g000881; Wed, 18 Nov 2009 08:07:20 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id nAIFo5ZD031290; Wed, 18 Nov 2009 07:50:05 -0800 Resent-Date: Wed, 18 Nov 2009 07:50:05 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Sullivan Beck Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Wed, 18 Nov 2009 15:50:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4954 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125855890130845 (code B ref -1); Wed, 18 Nov 2009 15:50:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 18 Nov 2009 15:41:41 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id nAIFfdDJ030842 for ; Wed, 18 Nov 2009 07:41:41 -0800 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NAmf5-0008DA-Ap for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 10:41:39 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NAmf0-0007zU-4y for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 10:41:38 -0500 Original-Received: from [199.232.76.173] (port=40269 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NAmez-0007z5-WA for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 10:41:34 -0500 Original-Received: from smtp04.osg.ufl.edu ([128.227.74.71]:35294 helo=smtp.ufl.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NAmez-0004DS-B7 for bug-gnu-emacs@gnu.org; Wed, 18 Nov 2009 10:41:33 -0500 Original-Received: from [128.227.212.53] (heather.osg.ufl.edu [128.227.212.53]) (authenticated bits=0) by smtp.ufl.edu (8.14.0/8.14.0/3.0.0) with ESMTP id nAIFfRln023882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 18 Nov 2009 10:41:30 -0500 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090915 SUSE/3.0b4-3.6 Thunderbird/3.0b4 X-Proofpoint-Virus-Version: vendor=fsecure engine=1.12.8161:2.4.5, 1.2.40, 4.0.166 definitions=2009-11-18_07:2009-11-16, 2009-11-18, 2009-11-18 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=5.0.0-0908210000 definitions=main-0911180108 X-UFL-Spam-Level: * X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Wed, 18 Nov 2009 11:07:28 -0500 X-Mailman-Approved-At: Wed, 18 Nov 2009 17:23:06 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32691 Archived-At: I wrote two simple emacs extensions, both of which use the run-at-time function periodically write some information to a file. When one or the other is loaded, emacs works fine. When both are loaded, emacs will work fine for a while, and then suddently start behaving very sluggishly. Keyboard input will not be printed on the screen for 2-4 seconds. It never seems to recover (though the periodic work should only take a fraction of a second) and eventually, I have to kill emacs and restart. I'll include both extensions below, though I don't believe that either of them are directly related to the cause of the problem... it just happened that they both use run-at-time. The first is to make the scratch buffer persistent. I (perhaps unwisely... but it's a habit I've gotten into) use the scratch buffer almost like a post-it note where I just jot things down and I don't want to lose it if my emacs gets shut down (either due to a system crash, power outage, or whatever). For safety, I save the buffer to a file every 5 minutes. ##### scratch.el #################################### ;; This makes the scratch buffer persistent. It will preserve the ;; contents of the buffer in a file stored in the variable scratch-file. ;; Whenever the scratch buffer is killed, it will automatically be ;; recreated with the old contents. If emacs is killed, the contents ;; will be placed in the scratch buffer the next time it is started. ;; The name of the file to preserve the scratch buffer in. (if (not (boundp 'scratch-file)) (setq scratch-file "~/.emacs.scratch")) (if (not (boundp 'scratch-autosave-interval)) (setq scratch-autosave-interval 300)) ;; If the *scratch* buffer is killed, recreate it automatically and ;; preserve the contents. (add-hook 'after-init-hook 'init-scratch-buffer) (add-hook 'after-init-hook 'init-scratch-autosave) (add-hook 'kill-emacs-hook 'kill-scratch-buffer) (defun init-scratch-buffer () (set-buffer (get-buffer-create "*scratch*")) (if (file-exists-p scratch-file) (insert-file-contents scratch-file)) (lisp-interaction-mode) (make-local-variable 'kill-buffer-query-functions) (add-hook 'kill-buffer-query-functions 'restart-scratch-buffer)) ;; This is called when we kill emacs. ;; Save *scratch*, kill *scratch*, don't restart it ;; (defun kill-scratch-buffer () (save-scratch-buffer) (save-current-buffer (set-buffer "*scratch*") (remove-hook 'kill-buffer-query-functions 'restart-scratch-buffer)) (kill-buffer "*scratch*")) ;; This saves the scratch buffer. ;; (defun save-scratch-buffer () (save-current-buffer (set-buffer "*scratch*") (write-region nil nil scratch-file))) ;; This restarts the scratch buffer. If we're currently in the scratch ;; buffer, come back to it. Otherwise, preserve the current buffer. ;; (defun restart-scratch-buffer () (setq currbuf (buffer-name)) (save-current-buffer ;; Kill the current (*scratch*) buffer (kill-scratch-buffer) ;; Make a brand new *scratch* buffer (init-scratch-buffer)) (if (string= currbuf "*scratch*") (switch-to-buffer "*scratch*")) ;; Since we killed it, don't let caller do that. nil) (defun init-scratch-autosave () (run-at-time t scratch-autosave-interval 'save-scratch-buffer)) ##### scratch.el #################################### The second, which is much less important (and it may be that there is an extension for doing this already) is that when I start up emacs, I like to automatically load the buffers that were loaded when emacs stopped. For safety, I also periodically saved the buffer list. Because I wanted the functionality of both, but couldn't deal with the hangs, I added an option to disable the periodic save of the buffer list (so it only gets saved when emacs is shut down nicely) and after that change was made, emacs worked fine. ##### bufferlist.el #################################### ;; This will store the list of open files when emacs is closed. When it ;; is restarted, it will attempt to reopen them. ;; The name of the file to preserve the buffer list in. (if (not (boundp 'bufferlist-file)) (setq bufferlist-file "~/.emacs.bufferlist")) (if (not (boundp 'bufferlist-autosave-interval)) (setq bufferlist-autosave-interval 300)) (add-hook 'after-init-hook 'init-bufferlist) (if (> bufferlist-autosave-interval 0) (add-hook 'after-init-hook 'init-bufferlist-autosave)) (add-hook 'kill-emacs-hook 'save-bufferlist) ;; This reads in the given buffer from the point to the end ;; of the line AND moves the point to the start of the next line. (defun read-text-line (buffer) ;; Switch to the buffer, and start a line at the current point. (setq line "") (save-current-buffer (set-buffer buffer) ;; Read characters until we get to EOL or EOB (while (and (not (eobp)) (not (eolp))) (setq c (following-char)) (setq line (concat line (char-to-string c))) (forward-char)) ;; If we're at EOL, move to the start of the next line (if (not (eobp)) (forward-char))) ;; Return line line) (defun eobp-buffer (buffer) (save-current-buffer (set-buffer buffer) (eobp))) (defun eolp-buffer (buffer) (save-current-buffer (set-buffer buffer) (eolp))) (defun save-bufferlist () ;; Create the bufferlist buffer (setq buflist "") (setq buflistbuf (generate-new-buffer "*bufferlist*")) ;; Insert the buffername and filename for all open files into this buffer (dolist (buffer (buffer-list)) (setq bufname (buffer-name buffer)) (save-current-buffer (set-buffer buffer) (setq filname buffer-file-name) (if buffer-file-name (progn (set-buffer buflistbuf) (insert bufname) (insert "\C-j") (insert filname) (insert "\C-j"))))) ;; Save the buffer to the file (save-current-buffer (set-buffer buflistbuf) (write-file bufferlist-file)) (kill-buffer buflistbuf)) (defun init-bufferlist () ;; Create the bufferlist buffer and insert the file into it. (save-current-buffer (setq buflistbuf (generate-new-buffer "*bufferlist*")) (set-buffer buflistbuf) (insert-file-contents-literally bufferlist-file)) ;; Load each buffer/file name (while (not (eobp-buffer buflistbuf)) (setq bufname (read-text-line buflistbuf)) (setq filname (read-text-line buflistbuf)) ;; Create the buffer. If it's different then it used to be, ;; rename it. (if (file-readable-p filname) (save-current-buffer (switch-to-buffer (find-file-noselect filname t nil nil)) (setq name (buffer-name)) (if (not (string= bufname name)) (rename-buffer bufname))))) ;; Clean up (kill-buffer buflistbuf)) (defun init-bufferlist-autosave () (run-at-time t bufferlist-autosave-interval 'save-bufferlist)) ##### bufferlist.el #################################### I'm sure there are other options available for both options... but these work for me, and I believe both should work without causing emacs to hang. They are loaded from my init.el file as: ##### init.el #################################### (setq scratch-file "~/..emacs/.scratch.") (load "scratch.elc" t t t) (setq bufferlist-autosave-interval 0) (setq bufferlist-file "~/..emacs/.bufferlist.") (load "bufferlist.elc" t t t) ##### init.el #################################### If I don't set bufferlist-autosave-interval to 0 (and use the default 5 minutes), emacs will hang. If I set it to 0 (which disables the autosave functionaity), everything works fine. Emacs doesn't crash, and I'm able to continue using it (though painfully). Thanks In GNU Emacs 23.1.1 (x86_64-suse-linux-gnu, GTK+ Version 2.18.1) of 2009-10-24 on build24 Windowing system distributor `The X.Org Foundation', version 11.0.10605000 configured using `configure '--with-pop' '--without-hesiod' '--with-kerberos' '--with-kerberos5' '--with-xim' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--with-x' '--with-sound' '--with-sync-input' '--with-xpm' '--with-jpeg' '--with-tiff' '--with-gif' '--with-png' '--with-rsvg' '--with-dbus' '--without-gpm' '--with-x-toolkit=gtk' '--x-includes=/usr/include' '--x-libraries=/usr/lib64:/usr/share/X11' '--with-xft' '--with-libotf' '--with-m17n-flt' '--build=x86_64-suse-linux' 'build_alias=x86_64-suse-linux' 'CC=gcc' 'CFLAGS=-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -D_GNU_SOURCE -std=gnu89 -pipe -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label -Wno-unprototyped-calls -DSYSTEM_PURESIZE_EXTRA=55000 -DSITELOAD_PURESIZE_EXTRA=10000 ' 'LDFLAGS=-Wl,-O2 -Wl,--hash-size=65521'' Important settings: value of $LC_ALL: C value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=local locale-coding-system: nil default-enable-multibyte-characters: t Major mode: CSS Minor modes in effect: show-paren-mode: t tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-y C-x r k C-SPC w C-y C-SPC C-w C-x C-s C-a C-SPC C-w C-x C-s C-a C-SPC C-w C-x C-s C-x C-f ~ / p e r s / p a s s w d C-s m o z i l l a C-s C-s C-s C-e g e t s a t i s f a c t i o n . c o m C-x C-s C-x k x r e p o r t SPC e m Recent messages: Saving file /home/sulbeck/.thunderbird/3crazqn6.default/chrome/userChrome.css... Wrote /home/sulbeck/.thunderbird/3crazqn6.default/chrome/userChrome.css Mark set Saving file /home/sulbeck/.thunderbird/3crazqn6.default/chrome/userChrome.css... Wrote /home/sulbeck/.thunderbird/3crazqn6.default/chrome/userChrome.css Wrote /home/sulbeck/..emacs/.scratch. [12 times] Mark saved where search started Saving file /home/sulbeck/pers/passwd... Wrote /home/sulbeck/pers/passwd Wrote /home/sulbeck/..emacs/.scratch. [18 times] -- --------------------------| Sullivan Beck |--------------------------- Email : sulbeck@ufl.edu | University of Florida Work Phone : (352) 273-1367 | Computing and Networking Services | 301 SSRB | Gainesville, FL 32611 ------------------------------------------------------------------------ For non-work related matters, please contact by email instead of phone ------------------------------------------------------------------------