* Re: [Stephen.Berman@gmx.net: Recentf and gzipped elisp source files]
@ 2005-11-24 10:01 David PONCE
0 siblings, 0 replies; 3+ messages in thread
From: David PONCE @ 2005-11-24 10:01 UTC (permalink / raw)
Cc: emacs-devel
Hi,
Richard M. Stallman wrote:
> Please DTRT and ack.
>
> ------- Start of forwarded message -------
[...]
> Since the change by which Emacs lisp source files are automatically
> gzipped if possible, these are not listed in the recentf menu under
> the entry "emacs-lisp" when recentf-menu-filter is set to
> recentf-arrange-by-mode, although such files are visited in
> emacs-lisp-mode; rather, they are listed under the entry "others".
[...]
Please, could you try the patch below. It fixes the problem for me.
David
2005-11-24 David Ponce <david@dponce.com>
* recentf.el (recentf-arrange-by-rule): Handle a special
`auto-mode-alist'-like "strip suffix" rule.
(recentf-build-mode-rules): Handle second level auto-mode entries.
Index: recentf.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/recentf.el,v
retrieving revision 1.48
diff -c -r1.48 recentf.el
*** recentf.el 14 Oct 2005 09:04:38 -0000 1.48
--- recentf.el 24 Nov 2005 09:44:59 -0000
***************
*** 813,826 ****
Arrange them in sub-menus following rules in `recentf-arrange-rules'."
(if (not recentf-arrange-rules)
l
! (let ((menus (mapcar #'(lambda (r) (list (car r)))
! recentf-arrange-rules))
! menu others min file rules elts count)
(dolist (elt l)
(setq file (recentf-menu-element-value elt)
rules recentf-arrange-rules
elts menus
menu nil)
(while (and (not menu) rules)
(when (recentf-match-rule-p (cdar rules) file)
(setq menu (car elts))
--- 813,832 ----
Arrange them in sub-menus following rules in `recentf-arrange-rules'."
(if (not recentf-arrange-rules)
l
! (let* ((strip (assq t recentf-arrange-rules))
! (menus (mapcar #'(lambda (r) (list (car r)))
! (remq strip recentf-arrange-rules)))
! menu others min file rules elts count)
! ;; Group menu items in the sub-menus defined in rules.
(dolist (elt l)
(setq file (recentf-menu-element-value elt)
rules recentf-arrange-rules
elts menus
menu nil)
+ ;; Apply the strip suffix rule.
+ (while (recentf-match-rule-p (cdr strip) file)
+ (setq file (substring file 0 (match-beginning 0))))
+ ;; Search in which group to put the menu item.
(while (and (not menu) rules)
(when (recentf-match-rule-p (cdar rules) file)
(setq menu (car elts))
***************
*** 828,836 ****
menu (cons elt (recentf-menu-element-value menu))))
(setq rules (cdr rules)
elts (cdr elts)))
(unless menu
(push elt others)))
!
(setq l nil
min (if (natnump recentf-arrange-by-rules-min-items)
recentf-arrange-by-rules-min-items 0))
--- 834,844 ----
menu (cons elt (recentf-menu-element-value menu))))
(setq rules (cdr rules)
elts (cdr elts)))
+ ;; Put unmatched menu-items in an "other" bin.
(unless menu
(push elt others)))
! ;; Setup the sub-menus from the groups of menu-items. Count
! ;; sub-menu elements, and apply sub-filter to menu-items.
(setq l nil
min (if (natnump recentf-arrange-by-rules-min-items)
recentf-arrange-by-rules-min-items 0))
***************
*** 845,851 ****
menu (recentf-apply-menu-filter
recentf-arrange-by-rule-subfilter (nreverse elts)))
(push menu l))))
!
(if (and (stringp recentf-arrange-by-rule-others) others)
(nreverse
(cons
--- 853,859 ----
menu (recentf-apply-menu-filter
recentf-arrange-by-rule-subfilter (nreverse elts)))
(push menu l))))
! ;; Add items in the "other" bin.
(if (and (stringp recentf-arrange-by-rule-others) others)
(nreverse
(cons
***************
*** 857,864 ****
(nconc
(nreverse l)
(recentf-apply-menu-filter
! recentf-arrange-by-rule-subfilter (nreverse others)))))
! ))
\f
;;; Predefined rule based menu filters
;;
--- 865,871 ----
(nconc
(nreverse l)
(recentf-apply-menu-filter
! recentf-arrange-by-rule-subfilter (nreverse others)))))))
\f
;;; Predefined rule based menu filters
;;
***************
*** 870,881 ****
(dolist (mode auto-mode-alist)
(setq regexp (car mode)
mode (cdr mode))
! (when (symbolp mode)
! (setq rule-name (symbol-name mode))
! (if (string-match "\\(.*\\)-mode$" rule-name)
! (setq rule-name (match-string 1 rule-name)))
! (setq rule-name (concat rule-name " (%d)")
! rule (assoc rule-name rules))
(if rule
(setcdr rule (cons regexp (cdr rule)))
(push (list rule-name regexp) rules))))
--- 877,896 ----
(dolist (mode auto-mode-alist)
(setq regexp (car mode)
mode (cdr mode))
! (when mode
! (cond
! ;; Build a special "strip suffix" rule from entries of the
! ;; form (REGEXP FUNCTION NON-NIL). Notice that FUNCTION is
! ;; ignored by the menu filter. So in some corner cases a
! ;; wrong mode could be guessed.
! ((and (consp mode) (cadr mode))
! (setq rule-name t))
! ((and mode (symbolp mode))
! (setq rule-name (symbol-name mode))
! (if (string-match "\\(.*\\)-mode$" rule-name)
! (setq rule-name (match-string 1 rule-name)))
! (setq rule-name (concat rule-name " (%d)"))))
! (setq rule (assoc rule-name rules))
(if rule
(setcdr rule (cons regexp (cdr rule)))
(push (list rule-name regexp) rules))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Stephen.Berman@gmx.net: Recentf and gzipped elisp source files]
@ 2005-11-24 12:55 David PONCE
2005-11-24 22:46 ` Stephen Berman
0 siblings, 1 reply; 3+ messages in thread
From: David PONCE @ 2005-11-24 12:55 UTC (permalink / raw)
Cc: rms, emacs-devel
Sorry, here is a better patch.
Index: recentf.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/recentf.el,v
retrieving revision 1.48
diff -c -r1.48 recentf.el
*** recentf.el 14 Oct 2005 09:04:38 -0000 1.48
--- recentf.el 24 Nov 2005 12:51:31 -0000
***************
*** 813,851 ****
Arrange them in sub-menus following rules in `recentf-arrange-rules'."
(if (not recentf-arrange-rules)
l
! (let ((menus (mapcar #'(lambda (r) (list (car r)))
! recentf-arrange-rules))
! menu others min file rules elts count)
(dolist (elt l)
! (setq file (recentf-menu-element-value elt)
! rules recentf-arrange-rules
! elts menus
! menu nil)
! (while (and (not menu) rules)
! (when (recentf-match-rule-p (cdar rules) file)
! (setq menu (car elts))
(recentf-set-menu-element-value
menu (cons elt (recentf-menu-element-value menu))))
! (setq rules (cdr rules)
! elts (cdr elts)))
! (unless menu
! (push elt others)))
!
! (setq l nil
! min (if (natnump recentf-arrange-by-rules-min-items)
! recentf-arrange-by-rules-min-items 0))
(dolist (menu menus)
! (when (setq elts (recentf-menu-element-value menu))
! (setq count (length elts))
(if (< count min)
! (setq others (nconc elts others))
(recentf-set-menu-element-item
menu (format (recentf-menu-element-item menu) count))
(recentf-set-menu-element-value
menu (recentf-apply-menu-filter
! recentf-arrange-by-rule-subfilter (nreverse elts)))
! (push menu l))))
!
(if (and (stringp recentf-arrange-by-rule-others) others)
(nreverse
(cons
--- 813,861 ----
Arrange them in sub-menus following rules in `recentf-arrange-rules'."
(if (not recentf-arrange-rules)
l
! (let* ((strip (assq t recentf-arrange-rules))
! (rules (remq strip recentf-arrange-rules))
! (menus (mapcar #'(lambda (r) (list (car r))) rules))
! others l1 l2 menu file min count)
! ;; Put menu items into sub-menus as defined by rules.
(dolist (elt l)
! (setq l1 menus ;; List of sub-menus
! l2 rules ;; List of corresponding matchers.
! file (recentf-menu-element-value elt)
! menu nil)
! ;; Apply the strip suffix rule.
! (while (recentf-match-rule-p (cdr strip) file)
! (setq file (substring file 0 (match-beginning 0))))
! ;; Search which sub-menu to put the menu item into.
! (while (and (not menu) l2)
! (when (recentf-match-rule-p (cdar l2) file)
! (setq menu (car l1))
(recentf-set-menu-element-value
menu (cons elt (recentf-menu-element-value menu))))
! (setq l1 (cdr l1)
! l2 (cdr l2)))
! ;; Put unmatched menu-items in the `others' bin.
! (or menu (push elt others)))
! ;; Finalize the sub-menus. That is, for each one:
! ;; - truncate it depending on the value of
! ;; `recentf-arrange-by-rules-min-items',
! ;; - Replace %d by the number of menu-items,
! ;; - apply `recentf-arrange-by-rule-subfilter' to menu-items.
! (setq min (if (natnump recentf-arrange-by-rules-min-items)
! recentf-arrange-by-rules-min-items 0)
! l2 nil)
(dolist (menu menus)
! (when (setq l1 (recentf-menu-element-value menu))
! (setq count (length l1))
(if (< count min)
! (setq others (nconc l1 others))
(recentf-set-menu-element-item
menu (format (recentf-menu-element-item menu) count))
(recentf-set-menu-element-value
menu (recentf-apply-menu-filter
! recentf-arrange-by-rule-subfilter (nreverse l1)))
! (push menu l2))))
! ;; Add the menu items remaining in the `others' bin.
(if (and (stringp recentf-arrange-by-rule-others) others)
(nreverse
(cons
***************
*** 853,864 ****
(format recentf-arrange-by-rule-others (length others))
(recentf-apply-menu-filter
recentf-arrange-by-rule-subfilter (nreverse others)))
! l))
(nconc
! (nreverse l)
(recentf-apply-menu-filter
! recentf-arrange-by-rule-subfilter (nreverse others)))))
! ))
\f
;;; Predefined rule based menu filters
;;
--- 863,873 ----
(format recentf-arrange-by-rule-others (length others))
(recentf-apply-menu-filter
recentf-arrange-by-rule-subfilter (nreverse others)))
! l2))
(nconc
! (nreverse l2)
(recentf-apply-menu-filter
! recentf-arrange-by-rule-subfilter (nreverse others)))))))
\f
;;; Predefined rule based menu filters
;;
***************
*** 870,881 ****
(dolist (mode auto-mode-alist)
(setq regexp (car mode)
mode (cdr mode))
! (when (symbolp mode)
! (setq rule-name (symbol-name mode))
! (if (string-match "\\(.*\\)-mode$" rule-name)
! (setq rule-name (match-string 1 rule-name)))
! (setq rule-name (concat rule-name " (%d)")
! rule (assoc rule-name rules))
(if rule
(setcdr rule (cons regexp (cdr rule)))
(push (list rule-name regexp) rules))))
--- 879,898 ----
(dolist (mode auto-mode-alist)
(setq regexp (car mode)
mode (cdr mode))
! (when mode
! (cond
! ;; Build a special "strip suffix" rule from entries of the
! ;; form (REGEXP FUNCTION NON-NIL). Notice that FUNCTION is
! ;; ignored by the menu filter. So in some corner cases a
! ;; wrong mode could be guessed.
! ((and (consp mode) (cadr mode))
! (setq rule-name t))
! ((and mode (symbolp mode))
! (setq rule-name (symbol-name mode))
! (if (string-match "\\(.*\\)-mode$" rule-name)
! (setq rule-name (match-string 1 rule-name)))
! (setq rule-name (concat rule-name " (%d)"))))
! (setq rule (assoc rule-name rules))
(if rule
(setcdr rule (cons regexp (cdr rule)))
(push (list rule-name regexp) rules))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Stephen.Berman@gmx.net: Recentf and gzipped elisp source files]
2005-11-24 12:55 [Stephen.Berman@gmx.net: Recentf and gzipped elisp source files] David PONCE
@ 2005-11-24 22:46 ` Stephen Berman
0 siblings, 0 replies; 3+ messages in thread
From: Stephen Berman @ 2005-11-24 22:46 UTC (permalink / raw)
This patch does the job, thanks! (I didn't try your first patch,
since you said this one is better.)
Steve Berman
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-11-24 22:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-24 12:55 [Stephen.Berman@gmx.net: Recentf and gzipped elisp source files] David PONCE
2005-11-24 22:46 ` Stephen Berman
-- strict thread matches above, loose matches on Subject: below --
2005-11-24 10:01 David PONCE
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).