;;;; menu-bar-setup.el -- JCGS's adjustments to menu bars ;;; Time-stamp: <2008-05-19 18:38:02 jcgs> (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (defun car-if-poss (a) (if (consp a) (car a) a)) (defun bring-to-top-of-menu (menu item) "In MENU, bring ITEM to the top." (progn ; condition-case var (let ((old (catch 'found (let* ((trailing menu) (find-old (cdr trailing))) (while find-old (if (eq (caar find-old) item) (throw 'found trailing) (setq trailing find-old find-old (cdr find-old))))) nil))) (if old (progn (rplacd menu (cons (cadr old) (cdr menu))) (rplacd old (cddr old))) (message "%S was not present in menu, so could not move it to top" item))) (error (message "Error in moving menu items")))) (defun replace-in-menu (menu old new) "In MENU, replace occurrences of OLD with NEW." (message "Replacing %S with %S in %S" old new menu) (let ((m (cdr menu))) (while m (let ((item (car m))) (message "Does %S match %S?" item old) (cond ((eq (cdddr item) old) (message "matched tail") ) ((eq (car item) old) (message "matched on car")) ((and (consp (cdddr item)) (>= (length item) 4) (eq (nth 1 item) 'menu-item) (eq (nth 3 item) old)) (message "matched menu-item")))) (setq m (cdr m))))) (condition-case error-var (progn (bring-to-top-of-menu menu-bar-help-menu 'describe) (bring-to-top-of-menu menu-bar-describe-menu 'describe-key) (bring-to-top-of-menu menu-bar-describe-menu 'describe-variable) (bring-to-top-of-menu menu-bar-describe-menu 'describe-function) ;; (replace-in-menu menu-bar-file-menu 'find-file 'flexi-find-file) ) (error (message "Problem in re-arranging menus"))) ;;; end of menu-bar-setup.el