From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bill Wohler Newsgroups: gmane.emacs.devel Subject: Re: Recent documents: Emacs and GNOME integration Date: Thu, 25 May 2006 10:22:31 -0700 Organization: Newt Software Message-ID: <87ejyi81ew.fsf@olgas.newt.com> References: <1147396844.567992.55920@i40g2000cwc.googlegroups.com> <7dbe73ed0605170050k53a88da4j81d723f2ea0202da@mail.gmail.com> <3c12eb8d0605170737p4f172fabya587f640eebbbbe6@mail.gmail.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1148577793 12970 80.91.229.2 (25 May 2006 17:23:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 May 2006 17:23:13 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 25 19:23:08 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FjJY8-0002eE-JO for ged-emacs-devel@m.gmane.org; Thu, 25 May 2006 19:23:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FjJY7-0006MS-HQ for ged-emacs-devel@m.gmane.org; Thu, 25 May 2006 13:23:03 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FjJXw-0006MA-8P for emacs-devel@gnu.org; Thu, 25 May 2006 13:22:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FjJXv-0006Lw-Lr for emacs-devel@gnu.org; Thu, 25 May 2006 13:22:51 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FjJXv-0006Lt-J7 for emacs-devel@gnu.org; Thu, 25 May 2006 13:22:51 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FjJcd-0005hP-8I for emacs-devel@gnu.org; Thu, 25 May 2006 13:27:43 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FjJXl-0002aw-Tf for emacs-devel@gnu.org; Thu, 25 May 2006 19:22:42 +0200 Original-Received: from h-68-166-189-198.snvacaid.dynamic.covad.net ([68.166.189.198]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 May 2006 19:22:41 +0200 Original-Received: from wohler by h-68-166-189-198.snvacaid.dynamic.covad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 May 2006 19:22:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 141 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: h-68-166-189-198.snvacaid.dynamic.covad.net User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:x3V9UhuvMh/6r9prcWdHzm5+nI0= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:55288 Archived-At: Richard Stallman writes: > So here's what I came up with based on the example in the spec: > > Would people please try it and report if it works? Sort of, with the following modifications (patch for some appended): 1. Add find-file-hook (so it will be called). However, do we want to add `update-recent-file' to the hook, or just call it from `basic-save-file' directly? 2. Don't add the ~/.recently-used file to the list unless the user opened it. The file should be invisible to the user. 3. Indent the XML to match the existing style of the file. I didn't give much thought to the new names, so please review to check for consistency and collisions. In addition, the following also has to be done, but I was not readily able to do so. 4. Suppress the "Wrote /home/wohler/.recently-used" message that appears every time you visit a file. 5. Don't add backup files to the list. The `private' and `groups' parameters aren't used by my hook. Shouldn't `update-recent-file' at least set groups to "Emacs" if it isn't given? --- recent-files.el.orig 2006-05-25 09:15:13.000000000 -0700 +++ recent-files.el 2006-05-25 10:19:23.000000000 -0700 @@ -8,19 +8,28 @@ (require 'url-util) (require 'mailcap) +(defvar updating-recent-file nil + "Non-nil means `update-recent-file' should skip `recent-files-name'. +It is set locally in `update-recent-file-item' and should NOT be +set in any other fashion.") + (defun update-recent-file (file &optional mime-type timestamp private &rest groups) "Add or update FILE's entry in `recent-files-name'." - (apply 'update-recent-file-item - (concat "file://" (mapconcat 'url-hexify-string - (split-string (expand-file-name file) "/") - "/")) - (or mime-type - (cdr (assoc (file-name-extension file t) mailcap-mime-extensions))) - (or timestamp - (format "%.f" (float-time))) - private - groups)) ; (cons "Emacs" groups) + (unless (and updating-recent-file + (equal file (expand-file-name recent-files-name))) + (apply 'update-recent-file-item + (concat "file://" (mapconcat 'url-hexify-string + (split-string + (expand-file-name file) "/") + "/")) + (or mime-type + (cdr + (assoc (file-name-extension file t) mailcap-mime-extensions))) + (or timestamp + (format "%.f" (float-time))) + private + groups))) ; (cons "Emacs" groups) (defun update-recent-file-item (uri mime-type timestamp &optional private &rest groups) @@ -35,7 +44,8 @@ (let* ((coding-system-for-read (intern (downcase recent-files-encoding))) (coding-system-for-write coding-system-for-read) (coding-system-require-warning t) - (recent-buffer (get-file-buffer recent-files-name))) + (recent-buffer (get-file-buffer recent-files-name)) + (updating-recent-file t)) (save-excursion (set-buffer (or recent-buffer (find-file-noselect recent-files-name))) @@ -62,9 +72,9 @@ (progn (setq group-start (match-end 0)) (setq group-end (search-forward-regexp ""))) - (insert "\n" "") + (insert "\n" " ") (setq group-start (point)) - (insert "\n" "") + (insert "\n" " ") (setq group-end (point-marker))) (goto-char group-start) (mapc (lambda (group) @@ -74,23 +84,30 @@ (regexp-quote group) "") nil group-end)) - (insert "\n" "" group ""))) + (insert "\n" " " + group " "))) groups)))) ;; else: Insert the new item: (search-forward "") (goto-char (match-beginning 0)) - (insert "") - (insert "\n" "" uri "" - "\n" "" mime-type "" - "\n" "" timestamp "") + (insert " ") + (insert "\n" " " uri "" + "\n" " " mime-type "" + "\n" " " timestamp "") (when groups - (insert "\n" "") + (insert "\n" " ") (mapc (lambda (group) - (insert "\n" "" group "")) + (insert "\n" " " group " ")) groups) - (insert "\n" "")) + (insert "\n" " ")) (when private - (insert "\n" "")) - (insert "\n" "" "\n")) + (insert "\n" " ")) + (insert "\n" " " "\n")) (save-buffer)) (or recent-buffer (kill-buffer (current-buffer)))))) + +(defun add-file-to-recent () + (when buffer-file-name + (update-recent-file buffer-file-name))) + +(add-hook 'find-file-hook 'add-file-to-recent) -- Bill Wohler http://www.newt.com/wohler/ GnuPG ID:610BD9AD Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian! If you're passed on the right, you're in the wrong lane.