• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/

Lines Matching +defs:menu +defs:item

1 ;;; recentf.el --- setup a menu of recently opened files
29 ;; This package maintains a menu for visiting files that were operated
30 ;; on recently. When enabled a new "Open Recent" sub menu is
31 ;; displayed in the "Files" menu. The recent files list is
33 ;; number of recent files displayed, the location of the menu and
57 "Maintain a menu of recently opened files."
62 "Group to customize recentf menu filters.
119 (defun recentf-menu-customization-changed (variable value)
120 "Function called when the recentf menu customization has changed.
121 Set VARIABLE with VALUE, and force a rebuild of the recentf menu."
125 (recentf-hide-menu)
127 (recentf-show-menu))
130 (defcustom recentf-menu-title "Open Recent"
131 "*Name of the recentf menu."
134 :set 'recentf-menu-customization-changed)
136 (defcustom recentf-menu-path '("File")
137 "*Path where to add the recentf menu.
138 If nil add it at top level (see also `easy-menu-add-item')."
142 :set 'recentf-menu-customization-changed)
144 (defcustom recentf-menu-before "Open File..."
145 "*Name of the menu before which the recentf menu will be added.
146 If nil add it at end of menu (see also `easy-menu-add-item')."
150 :set 'recentf-menu-customization-changed)
152 (defcustom recentf-menu-action 'find-file
153 "*Function to invoke with a filename item of the recentf menu.
158 (defcustom recentf-max-menu-items 10
159 "*Maximum number of items in the recentf menu."
163 (defcustom recentf-menu-filter nil
164 "*Function used to filter files displayed in the recentf menu.
168 Sort menu items in ascending order.
170 Sort menu items in descending order.
172 Sort menu items by filenames sans directory in ascending order.
174 Sort menu items by filenames sans directory in descending order.
176 Sort menu items by directories in ascending order.
178 Sort menu items by directories in descending order.
180 Show filenames sans directory in menu items.
190 Show a sub-menu for each major mode.
192 Show a sub-menu for each directory.
194 Manage a menu of filters.
196 The filter function is called with one argument, the list of menu
197 elements used to build the menu and must return a new list of menu
198 elements (see `recentf-make-menu-element' for menu element form)."
201 (function-item recentf-sort-ascending)
202 (function-item recentf-sort-descending)
203 (function-item recentf-sort-basenames-ascending)
204 (function-item recentf-sort-basenames-descending)
205 (function-item recentf-sort-directories-ascending)
206 (function-item recentf-sort-directories-descending)
207 (function-item recentf-show-basenames)
208 (function-item recentf-show-basenames-ascending)
209 (function-item recentf-show-basenames-descending)
210 (function-item recentf-relative-filter)
211 (function-item recentf-arrange-by-rule)
212 (function-item recentf-arrange-by-mode)
213 (function-item recentf-arrange-by-dir)
214 (function-item recentf-filter-changer)
217 (defcustom recentf-menu-open-all-flag nil
218 "*Non-nil means to show an \"All...\" item in the menu.
219 This item will replace the \"More...\" item."
223 (defcustom recentf-menu-append-commands-flag t
224 "*Non-nil means to append command items to the menu."
228 (define-obsolete-variable-alias 'recentf-menu-append-commands-p
229 'recentf-menu-append-commands-flag
289 "Whether to show ``[N]'' for the Nth item up to 10.
485 (defvar recentf-menu-items-for-commands
501 :help "Customize recently opened files menu and options"
504 "List of menu items for recentf commands.")
506 (defvar recentf-menu-filter-commands nil
507 "This variable can be used by menu filters to setup their own command menu.
508 If non-nil it must contain a list of valid menu-items to be appended
509 to the recent file list part of the menu. Before calling a menu
516 (defsubst recentf-make-menu-element (menu-item menu-value)
517 "Create a new menu-element.
518 A menu element is a pair (MENU-ITEM . MENU-VALUE), where MENU-ITEM is
519 the menu item string displayed. MENU-VALUE is the file to be open
522 sub-menu title and MENU-ELEMENTS is the list of menu elements in the
523 sub-menu."
524 (cons menu-item menu-value))
526 (defsubst recentf-menu-element-item (e)
527 "Return the item part of the menu-element E."
530 (defsubst recentf-menu-element-value (e)
531 "Return the value part of the menu-element E."
534 (defsubst recentf-set-menu-element-item (e item)
535 "Change the item part of menu-element E to ITEM."
536 (setcar e item))
538 (defsubst recentf-set-menu-element-value (e value)
539 "Change the value part of menu-element E to VALUE."
542 (defsubst recentf-sub-menu-element-p (e)
543 "Return non-nil if menu-element E defines a sub-menu."
544 (consp (recentf-menu-element-value e)))
546 (defsubst recentf-make-default-menu-element (file)
547 "Make a new default menu element with FILE.
548 This a menu element (FILE . FILE)."
549 (recentf-make-menu-element file file))
551 (defsubst recentf-menu-elements (n)
552 "Return a list of the first N default menu elements from the recent list.
553 See also `recentf-make-default-menu-element'."
554 (mapcar 'recentf-make-default-menu-element
557 (defun recentf-apply-menu-filter (filter l)
558 "Apply function FILTER to the list of menu-elements L.
559 It takes care of sub-menu elements in L and recursively apply FILTER
561 menu-elements (no sub-menu)."
566 ;; another of single menu elements.
568 (if (recentf-sub-menu-element-p elt)
574 ;; Apply FILTER to sub-menu elements.
577 (recentf-set-menu-element-value
578 elt (recentf-apply-menu-filter
579 filter (recentf-menu-element-value elt)))
581 ;; Return the new filtered menu element list.
585 ;; Count the number of assigned menu shortcuts.
586 (defvar recentf-menu-shortcuts)
588 (defun recentf-make-menu-items (&optional menu)
589 "Make menu items from the recent list.
590 This is a menu filter function which ignores the MENU argument."
591 (setq recentf-menu-filter-commands nil)
592 (let* ((recentf-menu-shortcuts 0)
595 (mapcar 'recentf-make-menu-item
596 (recentf-apply-menu-filter
597 recentf-menu-filter
598 (recentf-menu-elements recentf-max-menu-items)))
600 (message "recentf update menu failed: %s"
607 (if recentf-menu-open-all-flag
611 (and (< recentf-max-menu-items (length recentf-list))
613 :help "Open files not in the menu through a dialog"
615 (and recentf-menu-filter-commands '("---"))
616 recentf-menu-filter-commands
617 (and recentf-menu-items-for-commands '("---"))
618 recentf-menu-items-for-commands)))
620 (defun recentf-menu-value-shortcut (name)
627 (setq recentf-menu-shortcuts (1+ recentf-menu-shortcuts))
632 (defun recentf-make-menu-item (elt)
633 "Make a menu item from menu element ELT."
634 (let ((item (recentf-menu-element-item elt))
635 (value (recentf-menu-element-value elt)))
636 (if (recentf-sub-menu-element-p elt)
637 (cons item (mapcar 'recentf-make-menu-item value))
638 (let ((k (and (< recentf-menu-shortcuts 10)
639 (recentf-menu-value-shortcut value))))
640 (vector item
648 (,recentf-menu-action ,value)))
652 (defsubst recentf-menu-bar ()
653 "Return the keymap of the global menu bar."
654 (lookup-key global-map [menu-bar]))
656 (defun recentf-show-menu ()
657 "Show the menu of recently opened files."
658 (easy-menu-add-item
659 (recentf-menu-bar) recentf-menu-path
660 (list recentf-menu-title :filter 'recentf-make-menu-items)
661 recentf-menu-before))
663 (defun recentf-hide-menu ()
664 "Hide the menu of recently opened files."
665 (easy-menu-remove-item (recentf-menu-bar) recentf-menu-path
666 recentf-menu-title))
669 ;;; Predefined menu filters
672 "Sort the list of menu elements L in ascending order.
673 The MENU-ITEM part of each menu element is compared."
677 (recentf-menu-element-item e1)
678 (recentf-menu-element-item e2)))))
681 "Sort the list of menu elements L in descending order.
682 The MENU-ITEM part of each menu element is compared."
686 (recentf-menu-element-item e2)
687 (recentf-menu-element-item e1)))))
690 "Sort the list of menu elements L in ascending order.
695 (file-name-nondirectory (recentf-menu-element-value e1))
696 (file-name-nondirectory (recentf-menu-element-value e2))))))
699 "Sort the list of menu elements L in descending order.
704 (file-name-nondirectory (recentf-menu-element-value e2))
705 (file-name-nondirectory (recentf-menu-element-value e1))))))
708 "Sort the list of menu elements L in ascending order.
713 (recentf-menu-element-value e1)
714 (recentf-menu-element-value e2)))))
717 "Sort the list of menu elements L in descending order.
722 (recentf-menu-element-value e2)
723 (recentf-menu-element-value e1)))))
726 "Filter the list of menu elements L to show filenames sans directory.
731 (setq full (recentf-menu-element-value elt)
742 (push (recentf-make-menu-element name full) filtered-list))))
745 "Filter the list of menu elements L to show filenames sans directory.
752 "Filter the list of menu elements L to show filenames sans directory.
759 "Filter the list of menu-elements L to show relative filenames.
761 (mapcar #'(lambda (menu-element)
762 (let* ((ful (recentf-menu-element-value menu-element))
765 menu-element
766 (recentf-make-menu-element rel ful))))
770 ;;; Rule based menu filters
780 displayed title of the sub-menu where a '%d' `format' pattern is
781 replaced by the number of items in the sub-menu. MATCHER is a regexp
783 MATCHER are added to the corresponding sub-menu.
786 pair (SUB-MENU-TITLE . ITEM). SUB-MENU-TITLE is a computed sub-menu
787 title that can be another function. ITEM is the received item which
794 "*Title of the `recentf-arrange-by-rule' sub-menu.
795 This is for the menu where items that don't match any
797 displayed in the main recent files menu. A '%d' `format' pattern in
798 the title is replaced by the number of items in the sub-menu."
800 :type '(choice (const :tag "Main menu" nil)
804 "*Minimum number of items in a `recentf-arrange-by-rule' sub-menu.
805 If the number of items in a sub-menu is less than this value the
806 corresponding sub-menu items are displayed in the main recent files
807 menu or in the `recentf-arrange-by-rule-others' sub-menu if
813 "*Function called by a rule based filter to filter sub-menu elements.
814 A nil value means no filter. See also `recentf-menu-filter'.
841 "Filter the list of menu-elements L.
844 (let (menus others menu file min count)
845 ;; Put menu items into sub-menus as defined by rules.
847 (setq file (recentf-menu-element-value elt)
848 menu (recentf-match-rule file))
849 (while (functionp (car menu))
850 (setq menu (funcall (car menu) (cdr menu))))
851 (if (not (stringp (car menu)))
853 (setq menu (or (assoc (car menu) menus)
854 (car (push (list (car menu)) menus))))
855 (recentf-set-menu-element-value
856 menu (cons elt (recentf-menu-element-value menu)))))
857 ;; Finalize each sub-menu:
860 ;; - replace %d by the number of menu items,
861 ;; - apply `recentf-arrange-by-rule-subfilter' to menu items.
866 (setq menu (recentf-menu-element-value elt)
867 count (length menu))
869 (setq others (nconc menu others))
870 (recentf-set-menu-element-item
871 elt (format (recentf-menu-element-item elt) count))
872 (recentf-set-menu-element-value
873 elt (recentf-apply-menu-filter
874 recentf-arrange-by-rule-subfilter (nreverse menu)))
876 ;; Add the menu items remaining in the `others' bin.
880 ;; Put items in an sub menu.
883 (recentf-make-menu-element
886 (recentf-apply-menu-filter
888 ;; Append items to the main menu.
889 (recentf-apply-menu-filter
894 ;;; Predefined rule based menu filters
901 "Convert `auto-mode-alist' to menu filter rules.
912 ;; ignored by the menu filter. So in some corner cases a
930 "Split the list of menu-elements L into sub-menus by major mode."
936 "Filter the list of menu-elements L to show filenames sans directory.
941 (recentf-make-menu-element
942 (file-name-nondirectory (recentf-menu-element-value e))
943 (recentf-menu-element-value e)))
947 "Return as a sub-menu, the directory FILE belongs to."
951 "Split the list of menu-elements L into sub-menus by directory."
958 ;;; Menu of menu filters
971 the filter function, and LABEL is the menu item displayed to select
980 "Select FILTER as the current menu filter.
985 "Manage a sub-menu of menu filters.
986 `recentf-filter-changer-alist' defines the filters in the menu.
987 Filtering of L is delegated to the selected filter in the menu."
993 (setq recentf-menu-filter-commands
1007 (recentf-apply-menu-filter recentf-filter-changer-current l)))
1124 (recentf-dialog (format "*%s - Edit list*" recentf-menu-title)
1130 (dolist (item recentf-list)
1134 :tag item
1156 (funcall recentf-menu-action (widget-value widget)))
1162 "Filter the list of menu-elements L to show digit shortcuts."
1166 (recentf-set-menu-element-item
1167 e (format "[%d] %s" (% i 10) (recentf-menu-element-item e))))
1170 (defun recentf-open-files-item (menu-element)
1172 (if (consp (cdr menu-element))
1173 ;; Represent a sub-menu with a tree widget
1177 :node (item :tag ,(car menu-element)
1180 ,@(mapcar 'recentf-open-files-item
1181 (cdr menu-element)))
1183 `(link :tag ,(car menu-element)
1188 :help-echo ,(concat "Open " (cdr menu-element))
1190 ,(cdr menu-element))))
1196 (mapcar 'recentf-open-files-item
1202 (recentf-apply-menu-filter
1204 (mapcar 'recentf-make-default-menu-element
1207 (recentf-apply-menu-filter
1208 recentf-menu-filter
1209 (mapcar 'recentf-make-default-menu-element
1217 use for the dialog. It defaults to \"*`recentf-menu-title'*\"."
1221 (recentf-dialog (or buffer-name (format "*%s*" recentf-menu-title))
1228 ;; Use a L&F that looks like the recentf menu.
1242 "Show a dialog to open a recent file that is not in the menu."
1244 (recentf-open-files (nthcdr recentf-max-menu-items recentf-list)
1245 (format "*%s - More*" recentf-menu-title)))
1262 (funcall recentf-menu-action file)))
1342 When recentf mode is enabled, it maintains a menu for visiting files
1351 (recentf-show-menu))
1352 (recentf-hide-menu)