Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!ames!ucbcad!zen!postgres!grady From: grady@postgres (Steven Grady) Newsgroups: comp.emacs Subject: X popup menus Message-ID: <3342@zen.berkeley.edu> Date: Wed, 19-Aug-87 23:47:21 EDT Article-I.D.: zen.3342 Posted: Wed Aug 19 23:47:21 1987 Date-Received: Sat, 22-Aug-87 06:34:18 EDT Sender: news@zen.berkeley.edu Reply-To: grady@postgres (Steven Grady) Distribution: world Organization: Postgres Research Group, UC Berkeley Lines: 61 I was bored and had a little time, so decided to learn how to use (x-popup-menu).. Here's what I came up with: ---------------------------------------------------------------------- ;; ;; Stupid waste of time trying to find a use for x-popup-menu.. ;; ;; Use: (find-elisp-file) or M-x find-file-using-menu or something.. ;; ;; Steven Grady ;; grady@postgres.berkeley.edu ;; ...!ucbvax!grady ;; (defun find-elisp-file () "Find some elisp file. Warning - Slow!" (interactive) (find-file-using-menu "/usr/new/lib/emacs/lisp" ".el$")) (defun find-file-using-menu (directory &optional match) "Find file from DIRECTORY, with optional MATCH regexp." (interactive "DFrom directory? sRegexp match? ") (let ((menu (make-file-menu directory match))) (message "Creating menu...") (setq choice (car (x-popup-menu '(20 20) menu))) (if choice (find-file (concat directory choice))))) (defun make-file-menu (directory &optional match) (let ((files (directory-files directory nil match)) (split-files) (one-list) (pane) (menu '("Files"))) (setq split-files (split-big-list files 10)) (while (not (null split-files)) (setq one-list (car split-files)) (setq pane (list (make-pane-name one-list))) (while (not (null one-list)) (setq pane (append pane (list (list (car one-list) (car one-list))))) (setq one-list (cdr one-list))) (setq split-files (cdr split-files)) (setq menu (append menu (list pane)))) menu)) (defun make-pane-name (l) (concat (car l) "...")) (defun split-big-list (l n) (cond ((null l) l) (t (let ((i 0) (s nil)) (while (< i n) (setq i (+ 1 i)) (setq s (append s (list (car l)))) (setq l (cdr l)) (if (null l) (setq i (+ n 1)))) (append (list s) (split-big-list l n))))))