[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Recent documents: Emacs and GNOME integration
From: |
Bill Wohler |
Subject: |
Re: Recent documents: Emacs and GNOME integration |
Date: |
Thu, 25 May 2006 10:22:31 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Richard Stallman <address@hidden> 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 "</Groups>")))
- (insert "\n" "<Groups>")
+ (insert "\n" " <Groups>")
(setq group-start (point))
- (insert "\n" "</Groups>")
+ (insert "\n" " </Groups>")
(setq group-end (point-marker)))
(goto-char group-start)
(mapc (lambda (group)
@@ -74,23 +84,30 @@
(regexp-quote group)
"</Group>")
nil group-end))
- (insert "\n" "<Group>" group "</Group>")))
+ (insert "\n" " <Group>"
+ group " </Group>")))
groups))))
;; else: Insert the new item:
(search-forward "</RecentFiles>")
(goto-char (match-beginning 0))
- (insert "<RecentItem>")
- (insert "\n" "<URI>" uri "</URI>"
- "\n" "<Mime-Type>" mime-type "</Mime-Type>"
- "\n" "<Timestamp>" timestamp "</Timestamp>")
+ (insert " <RecentItem>")
+ (insert "\n" " <URI>" uri "</URI>"
+ "\n" " <Mime-Type>" mime-type "</Mime-Type>"
+ "\n" " <Timestamp>" timestamp "</Timestamp>")
(when groups
- (insert "\n" "<Groups>")
+ (insert "\n" " <Groups>")
(mapc (lambda (group)
- (insert "\n" "<Group>" group "</Group>"))
+ (insert "\n" " <Group>" group " </Group>"))
groups)
- (insert "\n" "</Groups>"))
+ (insert "\n" " </Groups>"))
(when private
- (insert "\n" "<Private/>"))
- (insert "\n" "</RecentItem>" "\n"))
+ (insert "\n" " <Private/>"))
+ (insert "\n" " </RecentItem>" "\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 <address@hidden> 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.
- Re: Recent documents: Emacs and GNOME integration, Richard Stallman, 2006/05/13
- Re: Recent documents: Emacs and GNOME integration, Mathias Dahl, 2006/05/17
- Re: Recent documents: Emacs and GNOME integration, Piotr Zielinski, 2006/05/17
- Re: Recent documents: Emacs and GNOME integration, Richard Stallman, 2006/05/17
- Re: Recent documents: Emacs and GNOME integration, Kevin Rodgers, 2006/05/24
- Re: Recent documents: Emacs and GNOME integration, Richard Stallman, 2006/05/24
- Re: Recent documents: Emacs and GNOME integration,
Bill Wohler <=
- Re: Recent documents: Emacs and GNOME integration, Kevin Rodgers, 2006/05/26
- Re: Recent documents: Emacs and GNOME integration, Stuart D. Herring, 2006/05/30
- Message not available
- Re: Recent documents: Emacs and GNOME integration, Stuart D. Herring, 2006/05/30
- Message not available
- Re: Recent documents: Emacs and GNOME integration, Stuart D. Herring, 2006/05/30
- Re: Recent documents: Emacs and GNOME integration, Stuart D. Herring, 2006/05/25
Re: Recent documents: Emacs and GNOME integration, Richard Stallman, 2006/05/17