;; Leninist.Biz! ;; Emacs-Time-stamp: "2006-12-14 23:41:32" (setq file-stamp "Emacs-File-stamp: \"/home/ysverdlov/leninist.biz/lb-tmm.el\"") ;; tmm.el: (require 'electric) ;; tmm.el: (defgroup lb-tmm nil "Text mode access to LB Edits menu-bar." :prefix "lb-tmm-" :group 'menu) ;; tmm.el: ;;; The following will be localized, added only to pacify the compiler. ;; tmm.el: ;; (defun tmm-menubar (&optional x-position) ;; ... ;; (tmm-prompt menu-bar nil menu-bar-item) ;; tmm.el: ;; (defun tmm-menubar-mouse ;; tmm.el: (defcustom lb-tmm-mid-prompt "=->" "*String to insert between shortcut and menu item. If nil, there will be no shortcuts. It should not consist only of spaces, or else the correct item might not be found in the `*Completions*' buffer." :type 'string :group 'lb-tmm) ;; tmm.el: (defvar lb-tmm-mb-map nil "A place to store minibuffer map.") ;; tmm.el: (defcustom lb-tmm-completion-prompt "Press PageUp Key to reach this buffer from the minibuffer. Etc. LBiz Etc. LBiz Etc. LBiz " "*Help text to insert on the top of the completion buffer. To save space, you can set this to nil, in which case the standard introduction text is deleted too." :type '(choice string (const nil)) :group 'lb-tmm) ;; tmm.el: (defcustom lb-tmm-shortcut-style '(downcase upcase) "*What letters to use as menu shortcuts. Must be either one of the symbols `downcase' or `upcase', or else a list of the two in the order you prefer." :type '(choice (const downcase) (const upcase) (repeat (choice (const downcase) (const upcase)))) :group 'lb-tmm) ;; tmm.el: (defcustom lb-tmm-shortcut-words 2 "*How many successive words to try for shortcuts, nil means all. If you use only one of `downcase' or `upcase' for `lb-tmm-shortcut-style', specify nil for this variable." :type '(choice integer (const nil)) :group 'lb-tmm) ;; tmm.el: ;; (defun tmm-prompt (menu &optional in-popup default-item) xxx ;; tmm.el: ;; (defun tmm-add-shortcuts ;; tmm.el: ;; (defsubst tmm-add-one-shortcut ;; tmm.el: ;; (defun tmm-define-keys ;; tmm.el: ;; (defun tmm-completion-delete-prompt ;; tmm.el: ;; (defun tmm-add-prompt ;; tmm.el: ;; (defun tmm-delete-map ;; tmm.el: ;; (defun tmm-shortcut ;; tmm.el: ;; (defun tmm-goto-completions ;; tmm.el: ;; (defun tmm-get-keymap ;; tmm.el: ;; (defun tmm-get-keybind ;; tmm.el: ;; (add-hook 'calendar-load-hook (lambda () (require 'cal-menu))) ;; tmm.el: ;; (provide 'tmm) ;; tmm.el: ;; DONE. ;; tmm.el: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar lb-keymap (make-sparse-keymap "LB Edits")) ;; (define-key lb-keymap [_-para-delete] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq lb-tmm-menubar '(search "LB Edits" keymap (search-forward "Search..." (nil) . nonincremental-search-forward) (separator-repeat "--") (_-para-delete "Delete paragraph" (nil) . _-para-delete) (separator-search "--") (bookmark "Bookmarks" . menu-bar-bookmark-map) (find-tag "Find Tag..." ([-134217682] . " (M-.)") . find-tag) (query-replace "Query Replace..." ([-134217691] . " (M-%)") . query-replace) "LB Edits") ) ;;;###autoload (defun lb-menubar (&optional x-position) "See: tmm-menubar" (interactive) (run-hooks 'menu-bar-update-hook) ;; Obey menu-bar-final-items; put those items last. (let ((menu-bar ;; (tmm-get-keybind [menu-bar]) lb-tmm-menubar ) menu-bar-item) (when nil (let ((list menu-bar-final-items)) (while list (let ((item (car list))) ;; ITEM is the name of an item that we want to put last. ;; Find it in MENU-BAR and move it to the end. (let ((this-one (assq item menu-bar))) (setq menu-bar (append (delq this-one menu-bar) (list this-one))))) (setq list (cdr list)))) );;OFF (when nil (if x-position (let ((tail menu-bar) this-one (column 0)) (while (and tail (< column x-position)) (setq this-one (car tail)) (if (and (consp (car tail)) (consp (cdr (car tail))) (stringp (nth 1 (car tail)))) (setq column (+ column (length (nth 1 (car tail))) 1))) (setq tail (cdr tail))) (setq menu-bar-item (car this-one)))) );;OFF (tmm-prompt menu-bar nil menu-bar-item))) ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; EXAMPLE: ;; (tmm-get-keybind [menu-bar]) ;; Just "Search" from above: (setq lb-tmm-search '(search "Search" keymap (search-forward "Search..." (nil) . nonincremental-search-forward) (re-search-forward "Regexp Search..." (nil) . nonincremental-re-search-forward) ;; ... (separator-repeat "--") (repeat-search-fwd "Repeat Search" (nil) . nonincremental-repeat-search-forward) (repeat-regexp-fwd "Repeat Regexp" (nil) . nonincremental-repeat-re-search-forward) ;; ... (separator-search "--") (bookmark "Bookmarks" . menu-bar-bookmark-map) (find-tag "Find Tag..." ([-134217682] . " (M-.)") . find-tag) ;; (query-replace "Query Replace..." ([-134217691] . " (M-%)") . query-replace) (query-replace-regexp "Query Replace Regexp..." ([-67108827] . " (C-M-%)") . query-replace-regexp) "Search") ) ;; EXAMPLE: ;; (tmm-prompt lb-tmm-search) ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (global-set-key [C-f12] 'lb-menubar) (provide 'lb-tmm) ;;; ;