home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / interfaces / simple-menu2.el < prev    next >
Encoding:
Text File  |  1991-06-10  |  23.8 KB  |  606 lines

  1. ;;; Simple Menu Enhancements for GNU Emacs
  2. ;;;
  3. ;;; Version 1.1
  4. ;;; 6-5-91 - added ability to show esc-x commands in help
  5. ;;; 5-27-91 - added ability to show esc-x commands after command completion
  6. ;;; 2 may 91 added (require 'cl) reported by dfreuden@shearson.com,
  7. ;;;          ne201ph@prism.gatech.edu (Halvorson,Peter J) & others
  8. ;;;
  9. ;;; COPYRIGHT and WARNINGS
  10. ;;;
  11. ;;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;;; but WITHOUT ANY WARRANTY.  No author or distributor
  13. ;;; accepts responsibility to anyone for the consequences of using it
  14. ;;; or for whether it serves any particular purpose or works at all,
  15. ;;; unless he says so in writing.  Refer to the GNU Emacs General Public
  16. ;;; License for full details.
  17. ;;;
  18. ;;; Everyone is granted permission to copy, modify and redistribute
  19. ;;; GNU Emacs, but only under the conditions described in the
  20. ;;; GNU Emacs General Public License.   A copy of this license is
  21. ;;; supposed to have been given to you along with GNU Emacs so you
  22. ;;; can know your rights and responsibilities.  It should be in a
  23. ;;; file named COPYING.  Among other things, the copyright notice
  24. ;;; and this notice must be preserved on all copies.
  25. ;;;
  26. ;;; Copyright (C) 1991 Frank Ritter.  Same license as above.
  27. ;;; Updated versions (if any) are available from the author or via ftp:
  28. ;;; from the elisp archive on tut.cis.ohio-state.edu as file
  29. ;;;  pub/gnu/emacs/elisp-archive/interfaces/simple-menu2.el.Z
  30. ;;;
  31. ;;; Initially based on code posted by Chris Ward.
  32. ;;;        Texas Instruments 
  33. ;;;        (cward@houston.sc.ti.com)       (214) 575-3128
  34. ;;;        (X.400: /ADMD=MCI/PRMD=TI/C=US/G=Chris/S=Ward MCI_Mail_ID #4418566)
  35. ;;; and posted comments on Chris's code by Erik Hennum (Erik@informix.com)
  36. ;;;
  37. ;;;    OVERVIEW/INTRODUCTION
  38. ;;; 
  39. ;;; Simple-menu is a way to provide simple menus, rather reminiscent of
  40. ;;; the menus provided by the PDP software of McClellend & Rumelhart.  With
  41. ;;; the simple menus defined here for gnu-emacs, an initial menu of
  42. ;;; commands is displayed in the message line by calling run-menu on a
  43. ;;; previously defined menu.  The user types the first letter of an item to 
  44. ;;; select it, and a command gets executed, or a sub-menu is entered.
  45. ;;; Often you will bind the top menu call to a key.
  46. ;;;
  47. ;;; The prompt that is displayed includes a reminder that help is available  
  48. ;;; by typing ``?''.  (Help is also available by typing ^h or SPC.)
  49. ;;; 
  50. ;;; Simple menus are defined with def-menu.  This takes a menu-name, an
  51. ;;; title, an intro help comment (ie.: "Pick a command"), and a list of
  52. ;;; items to be put on the menu.  Each  menu item is a list with 2 
  53. ;;; components: 1) a display string, and 2) the command corresponding 
  54. ;;; to the string.  The first word is put in the menu, the first letter in
  55. ;;; the string is used as the selector for the item (case insensitive),
  56. ;;; and the whole string is used in the help display.  
  57. ;;; Def-menu and sm-add-to-menu allow you add commands to menus after they have
  58. ;;; been created.
  59. ;;;
  60. ;;; For example, the menu item:
  61. ;;; 
  62. ;;; ("Redraw         Redraw the screen."   recenter)
  63. ;;; 
  64. ;;; would create the item Redraw in the menu, and the letter R would
  65. ;;; select it.  In the help display, the full string would appear, along
  66. ;;; with any keybindings for the command in the local buffer, in this case
  67. ;;; the help line would look like 
  68. ;;; 
  69. ;;; Redraw         Redraw the screen. (C-l)
  70. ;;; 
  71. ;;; The command given as the second argument can be either: 1) a simple
  72. ;;; function name, 2) a list to eval, or 3) a menu name (symbol).  If you
  73. ;;; want two commands there, wrap them in a progn because the internals of
  74. ;;; the program use each list position.
  75. ;;;
  76. ;;; If there is only one menu item, it is executed when the menu is run.
  77. ;;; After an item is selected and sucessfully completed, a possible keybinding
  78. ;;; or call via meta-X is displayed if possible.
  79. ;;;
  80. ;;;  Here's an example:
  81. ;;; 
  82. ;;; (def-menu simple-menu
  83. ;;;   "Choose a simple command"
  84. ;;;   "Here are some simple commands to choose"
  85. ;;;  (("Add 2 + 2      Add 2+2 and print it out for me."
  86. ;;;    (progn (message (format "The Answer is %s." (+ 2 2)))
  87. ;;;           (sleep-for 2)))
  88. ;;;   ("Redraw         Redraw the screen." recenter)
  89. ;;;   ("Simple menu    Recurse and run this darn menu again." simple-menu)))
  90. ;;; 
  91. ;;; Run-menu will start up the menu.  ^g will abort the menu.
  92. ;;; eg.
  93. ;;; (run-menu 'simple-menu)
  94. ;;; Binding this to a key makes the menu more usable.
  95. ;;; 
  96.  
  97. (require 'cl)
  98. (provide 'simple-menu)
  99.  
  100.  
  101. ;;; 
  102. ;;;     I.    Variables and constants 
  103. ;;;
  104.  
  105. ;; uses main help buffer, used to be *MENU Help*
  106. (defconst help-buffer "*Help*")
  107.  
  108. (defconst simple-menu-help-string "(?):")
  109.  
  110. (defconst sm-default-help-header "Commands in the")
  111. (defconst sm-default-help-for-help 
  112.   "? or ^h or space to display this text at the first prompt.")
  113. (defconst sm-default-help-footer "^G or space-bar to quit this menu now.
  114.  First letter of the line to choose a command.")
  115. (defconst CR "
  116. ")
  117.  
  118. ; menus have the following fields:
  119. ;  prompt - the string used as the prompt before the choices
  120. ;  full-prompt - the string put in the message line
  121. ;  items - the list of items
  122. ;  prompt-header  - 
  123. ;  help-header - header for the help buffer
  124.  
  125.  
  126. ;;;
  127. ;;;     II.    Creating functions
  128. ;;;
  129. ;; menus are symbols, 
  130. ;; the raw items are stored under the plist 'items
  131. ;; the list that is displayed is stored in their value, 
  132. ;;    it is made by calling sm-menu-ized-items on the items, 
  133. ;; the prompt-header is under the 'prompt-header property
  134. ;; the help-header   is under the 'help-header prop.
  135.  
  136.  
  137. (defun sm-def-menu (name prompt help-header items)
  138.  "define a menu object"
  139.  ;; check for errors on the way in and massage args
  140.  (if (not (symbolp name)) 
  141.      (error (format "%s, the first arg must be a symbol." name)))
  142.  (cond 
  143.    ( (get name 'items) ;it's been created already
  144.      (sm-add-to-menu name items) 
  145.      (put name 'prompt-header prompt)
  146.      (put name 'help-header help-header))
  147.    (t  ;; doit
  148.      (put name 'items items)
  149.      (set name (sm-menu-ized-items items))
  150.      (put name 'prompt-header prompt)
  151.      (put name 'help-header help-header)
  152.      t)) )
  153.  
  154. (fset 'def-menu 'sm-def-menu)
  155.  
  156. (defun sm-add-to-menu (menu items)
  157.   "Add to NAME the list of ITEMS."
  158.   (mapcar '(lambda (x) (sm-add-to-menu-item menu x))
  159.           items))
  160.  
  161. (defun sm-add-to-menu-item (menu item)
  162.   (let ( (old-items (get menu 'items)) )
  163.    (cond ( (member item old-items) )
  164.          (t 
  165.            (put menu 'items (append old-items items))
  166.            (set menu (sm-menu-ized-items (get menu 'items)))
  167.            (put menu 'full-prompt nil)))
  168.   ))
  169.  
  170. (fset 'add-to-menu 'sm-add-to-menu)
  171. ;;;
  172. ;;;        Running functions
  173. ;;;
  174.  
  175. (defun sm-run-menu (amenu)
  176.  "present a menu"
  177.  ;; get & present the prompt
  178.  (if (= (length (eval amenu)) 1)
  179.      (sm-eval-single-menu amenu)
  180.  (let ((prompt (get amenu 'prompt-header))
  181.        (full-prompt (get amenu 'full-prompt))
  182.        (old-window (selected-window))
  183.        (items (eval amenu))    )
  184.   (if (not (string= prompt "")) (setq prompt (concat prompt ": ")))
  185.   (if full-prompt
  186.       (message full-prompt)
  187.       (progn
  188.         ;; this makes a full prompt, & saves it for later use
  189.         (mapcar (function (lambda (x) (setq prompt (concat prompt x " "))))
  190.                 (mapcar 'first-word items))
  191.         (setq prompt (concat prompt simple-menu-help-string))
  192.         (put amenu 'full-prompt prompt)
  193.         (message prompt)))
  194.   ;; read it in & process char choice
  195.   (let ( (cursor-in-echo-area t)
  196.          (echo-keystrokes 0) )
  197.   (setq opt (read-char)) )
  198.   (setq opt (downcase opt))
  199.   (if (or (= opt ?\C-h) (= opt ??)  (= opt ? ))
  200.       (setq opt (downcase (pop-up-help amenu))))
  201.   (sm-eval-menu amenu opt)
  202.  )))
  203.  
  204. (fset 'run-menu 'sm-run-menu)
  205.  
  206.  
  207. ;;;
  208. ;;;     III.     Helper functions 
  209. ;;; 
  210.  
  211. (defun sm-eval-menu (amenu opt)
  212.  "find in AMENU the command corresponding to OPT."
  213.  (let ( (items (eval amenu)) 
  214.         (command nil) )
  215.   (while items
  216.      (setq item (pop items))
  217.      (cond ( (= opt (third item))
  218.              (setq items nil)
  219.              (setq command (second item))
  220.              (cond ;; its a command
  221.                    ((and (not (listp command)) (fboundp command))
  222.                     (call-interactively command)
  223.             (sm-note-function-key command))
  224.                    ;; it is something to eval
  225.                    ((listp command)
  226.                     (eval command))
  227.                    ;; it is another menu, you hope...
  228.                    (t (sm-run-menu command))))))
  229.   (if (not command) ; no match
  230.       (progn (message (format "%c did not match a menu name" opt))
  231.              (beep)))      ;note we lost
  232. ))
  233.  
  234. (defun sm-eval-single-menu (amenu)
  235.  "run in AMENU the single only command."
  236.  (let* ( (item (first (eval amenu)))
  237.          (command (second item)) )
  238.    (cond ;; its a command
  239.         ((and (not (listp command)) (fboundp command))
  240.          (call-interactively command)
  241.          (sm-note-function-key command))
  242.         ;; it is something to eval
  243.         ((listp command)
  244.          (eval command))
  245.         ;; it is another menu, you hope...
  246.         (t (sm-run-menu command)))
  247.    (if (not command) ; no match
  248.        (progn (message (format "%c did not match a menu name" opt))
  249.               (beep)))     ;note we lost
  250. ))
  251.  
  252. (defun sm-make-help (help-header name items)
  253.  "make a help string for a simple menu"
  254.  (let ((header nil) (result ""))
  255.   (setq result
  256.         (concat result
  257.                (cond ((string= "" help-header)
  258.                       (format "%s %s:%s" sm-default-help-header name CR CR))
  259.                      (t (concat help-header ":" CR CR)))))
  260.   (mapcar (function 
  261.             (lambda (x) 
  262.                (let ((bind-thing (sm-find-binding (car (cdr x))))
  263.                      (help-string (car x)) )
  264.                (setq result (format "%s %s " result help-string))
  265.                (if bind-thing
  266.                    (setq result (format "%s (%s)" result bind-thing)))
  267.                (setq result (concat result CR))           )))
  268.           items)
  269.   (setq result (concat result CR " " sm-default-help-for-help ))
  270.   (setq result (concat result CR " " sm-default-help-footer))
  271.   result))
  272.  
  273. (defun sm-find-binding (function)
  274.  "Finds a keybinding for function if it can."
  275.  (cond
  276.    ((car (where-is-internal function (current-local-map))))
  277.     ;; check escape map too
  278.    ( (let ((esc-key (where-is-internal function 
  279.                                        (lookup-key (current-local-map) ""))))
  280.       (if esc-key
  281.          (concat "M-" (car esc-key)))))
  282.    ( (symbolp function)
  283.      ;; this assumes that function in interactive
  284.      (message (format "\"ESC-X %s\""
  285.                   function)))))
  286.              
  287.  
  288. (defun sm-menu-ized-items (items)
  289.  "strips the first letter off and makes it the third item for ease and speed"
  290.  (mapcar (function (lambda (x) (append x (list (string-to-char (first-letter x))))))
  291.          items))
  292.  
  293.  
  294. (defun pop-up-help (menu)
  295.   "Display the full documentation of MENU."
  296.   ;; changed to work on menu items.
  297.   (let ((opt nil) (opt-key 'beep) (full-prompt (get menu 'full-prompt))
  298.         (help-info 
  299.            (cond ((get menu 'help))
  300.                  ((put menu 'help (sm-make-help (get menu 'help-header)
  301.                                                 menu
  302.                                                 (get menu 'items))))
  303.                  (t "not documented")))  )
  304.     (save-window-excursion
  305.       (switch-to-buffer help-buffer)
  306.       (erase-buffer)
  307.       (insert help-info)
  308.       (goto-char (point-min))
  309.       (while (not (equal opt-key 'self-insert-command))
  310.         (message full-prompt)
  311.         (setq opt (read-key-sequence nil))
  312.         (setq opt-key (lookup-key (current-global-map) opt))
  313.         (if (memq opt-key 
  314.                   (append 
  315.                    (if (not (pos-visible-in-window-p (point-min)))
  316.                        '(scroll-up))
  317.                    (if (not (pos-visible-in-window-p (point-max)))
  318.                        '(scroll-down))
  319.                    '(next-line previous-line forward-line forward-char 
  320.                      backward-char keyboard-quit scroll-right scroll-left)))
  321.             (call-interactively opt-key)
  322.           (bury-buffer help-buffer))))
  323.     (string-to-char opt)))
  324.  
  325. (defun sm-note-function-key (command)
  326.  "Note to the user any keybindings for Command"
  327.  (let ( (key-binding (sm-find-binding command)) )
  328.    ;(setq aa command)
  329.   (cond
  330.    (key-binding
  331.     (message (format "%s is also bound to \"%s\"."
  332.              command key-binding))) )))
  333.  
  334.  
  335. ;;;
  336. ;;;     IV.    Utilities
  337. ;;; 
  338.  
  339. ;; (first-word '("asdf" fun1))
  340. ;; (first-letter '("Asdf" fun1))
  341.  
  342. (defun first-word (menu-item)
  343.  "return the first word of the first part (a string) of MENU-ITEM"
  344.  (let ((string  (car menu-item)))
  345.   (substring string 0 (string-match " " string))))
  346.  
  347. (defun first-letter (menu-item)
  348.  "return the first letter of the first part (a string) of MENU-ITEM"
  349.  (let ((string  (first-word menu-item)))
  350.     (downcase (substring string 0 1))))
  351.  
  352. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  353. ;; sample usage:
  354. ;
  355. ;(defun run-soar-menu () 
  356. ;  "provide a menu of commands for Soar and Taql."
  357. ;  (interactive)
  358. ;  (run-menu 'soar-menu))
  359. ;
  360. ;(def-menu
  361. ;  'soar-menu
  362. ;  "" ;main prompt
  363. ;  "The menu key allows you to select various command options" ;help prompt
  364. ;   ;123456789012345
  365. ; '(("Documents       Examine various manuals."   soar-document-menu)
  366. ;   ("Emacs           Do plain Emacs commands."   emacs-menu)
  367. ;   ("Soar            Do primarily Soar commands." soar-command-menu)
  368. ;   ("Lisp            Do primarily Lisp commands." lisp-command-menu)
  369. ;))
  370. ;
  371. ;(def-menu
  372. ;  'soar-document-menu 
  373. ;  "" ;main prompt
  374. ;  "The menu key allows you to select various documents to browse:" ;help prompt
  375. ;  ;; all manuals should live in the manuals sub-directory
  376. ; '(("1-Soar5.2    Main Soar manual."       (goto-manual "Soar5-manual.doc"))
  377. ;   ("2-soar-mode  soar-mode manual."       (goto-manual "soar-mode.doc"))
  378. ;   ("3-DSI        DSI manual.      "       (goto-manual "dsi-manual.doc"))
  379. ;))
  380. ;
  381. ;(def-menu 
  382. ;   'emacs-menu
  383. ;  "Emacs commands"
  384. ;  "Menu of plain Emacs commands"
  385. ; '(("Windows      Manipulate multiple window settings."            windows-menu)
  386. ;   ("Modify       Change your editing environment."                modify-menu)
  387. ;   ("Block menu   Perform operations on blocks (regions) of text." block-menu)
  388. ;))
  389. ;
  390. ;(def-menu  'block-menu
  391. ;  "Block Option"
  392. ;  "Displays menu of block commands to chose from"
  393. ; '(("Align    Adjust all lines in region Left, Right, or Centered." align-menu)
  394. ;  ("Eval     Evaluate region as a Lisp expression."                eval-region)
  395. ;  ("Fill     Fill each paragraph in the region."                   fill-region)
  396. ;  ("Indent   Indent region according to major mode."          indent-region)
  397. ;  ("Lower    Convert all characters in region to lowercase."  downcase-region)
  398. ;  ("Narrow   Narrow scope of edit to region."                 narrow-to-region)
  399. ;  ("Spell    Check spelling of all words in region."          spell-region)
  400. ;  ("Upcase   Convert all characters in region to uppercase."  upcase-region)
  401. ;  ))
  402. ;
  403. ;
  404. ;(def-menu 'modify-menu
  405. ;  "Modify Option"
  406. ;  "Modify editing environment options are"
  407. ; '(("Keys     Locally rebind a key to a function."      local-set-key)
  408. ;  ("Mode     Change current major/minor mode."         mode-menu)
  409. ;  ("Options  Change environmental variable values."    (edit-options))
  410. ;  ("Save     Save current options settings to a file."
  411. ;   (message "Modify Save not implemented yet."))
  412. ;  ("Tabs     Modify tab stop locations."               edit-tab-stops))  )
  413. ;
  414. ;(def-menu 'soar-command-menu
  415. ;  "Soar Options"
  416. ;  "" ;help prompt
  417. ; '(
  418. ;   ("Run          Switch to the running Soar buffer." switch-to-lisp)
  419. ;   ("Break        Interupt current lisp."  
  420. ;                 (progn (switch-to-lisp t)
  421. ;                        (interrupt-subjob-ilisp)))
  422. ;   ("Prod         Do stuff to productions." production-command-menu)
  423. ;   ("Load         load TC or production into Soar." 
  424. ;                  eval-defun-and-go-lisp)
  425. ;   ("Commands     Other commands in soar-mode."   other-soar-command-menu)
  426. ;   ("Varset       menu to set variables."   soar-variables-menu)))
  427. ;
  428. ;(def-menu 'other-soar-command-menu
  429. ;  "Other Soar commands"
  430. ;  "" ;help prompt
  431. ; '(
  432. ;   ("Header       Make a file header." make-header)
  433. ;   ("Rev          Make a revision line in header." make-revision)
  434. ;   ("Tag          Make a tags table for a list of files." make-tags-table)
  435. ;   ("Rtags        Remake a tags table for a list of files.
  436. ;                   (This is faster than Tag.)"           remake-tags-table)
  437. ;   ("Count        Count the number of productions in current buffer."
  438. ;                  soar-count-productions)
  439. ;))
  440. ;
  441. ;(def-menu 'production-command-menu
  442. ;  "Production"
  443. ;  "" ;help prompt
  444. ;
  445. ; '(("Trace        Traces the previous production." soar-ptrace-production)
  446. ;   ("Full         Full-matches on production." soar-full-matches-production)
  447. ;   ("Xcise        Excise production."     soar-excise-production)
  448. ;   ("Smatch       SMatch production."  soar-smatches-production)
  449. ;   ("Break        Pbreak production." soar-pbreak-production)
  450. ;   ("Prin         SPR production."  soar-spr-production)
  451. ;   )
  452. ;)
  453. ;
  454. ;(def-menu 'lisp-command-menu
  455. ;  "Lisp"
  456. ;  "" ;help prompt
  457. ; '(("Arg          Apropos on CL manual." fi:clman-apropos)
  458. ;   ("Doc          Check Common Lisp manual." fi:clman)
  459. ;   ("UDoc         Get documentation string." documentation-lisp)
  460. ;   ("Xpand        macroexpand-lisp."        macroexpand-lisp)
  461. ;   ("0Eval        Eval the surrounding defun." eval-defun-lisp)
  462. ;   ("1Eval        Eval defun and goto Soar." eval-region-and-go-lisp)
  463. ;   ("Rglist       Get the arglist for function." arglist-lisp)
  464. ;   (";            Comment the region."   comment-region-lisp)
  465. ;   (")            find-unbalanced-lisp parens." find-unbalanced-lisp)
  466. ;   ("Prev         Display the previous input." comint-previous-input)
  467. ;   ("]            close-all-lisp parens that are open." close-all-lisp)
  468. ;   ("Trace        Traces the previous function symol." trace-lisp)
  469. ;   )
  470. ;)
  471. ;
  472. ;;; example of leaving old format in
  473. ;(defun replace-menu ()
  474. ;  "Options for finding & replacing strings in current buffer:
  475. ; Interactive  Check each occurance before replace. [default]
  476. ; All          Replace all occurances without asking.
  477. ; -------
  478. ; Regexp   Search & replace using a regular expression.
  479. ; String   Search & replace any string of characters.
  480. ; Tags     Search & replace through all files listed in tag table.
  481. ;"
  482. ;  (interactive)
  483. ;  (let ((prompt "Replace: All Help Regexp String Tag ")
  484. ;        (opt nil)
  485. ;        (forward t)
  486. ;        (interactive t))
  487. ;    (while (not opt)
  488. ;      (message prompt)
  489. ;      (setq opt (downcase (read-char)))
  490. ;      (if (= opt ?h) (setq opt (pop-up-help 'replace-menu "Replace option: ")))
  491. ;      (cond ((= opt ?i)                 ; Set for interactive search
  492. ;             (setq interactive t)
  493. ;             (setq prompt "Replace: All Help Regexp String Tag ")
  494. ;             (setq opt nil))
  495. ;            ((= opt ?a)                 ; Set for noninteractive search
  496. ;             (setq interactive nil)
  497. ;             (setq prompt "Replace: Interactive Help Regexp String Tag ")
  498. ;             (setq opt nil))
  499. ;            ((= opt ?s)                 ; String replace
  500. ;             (if interactive (call-interactively 'query-replace)
  501. ;               (call-interactively 'replace-string)))
  502. ;            ((= opt ?r)                 ; Regexp search
  503. ;             (if interactive (call-interactively 'query-replace-regexp)
  504. ;               (call-interactively 'replace-regexp)))
  505. ;            ((= opt ?t)                 ; Tags search
  506. ;             (call-interactively 'tags-query-replace))
  507. ;            (t (ding)))))
  508. ;  )
  509. ;
  510. ;
  511. ;(def-menu 'windows-menu 
  512. ;  ""
  513. ;  "Displays menu of window commands to chose from"
  514. ; '(("Buffers  Change to buffers menu."                             buffer-menu) 
  515. ;  ("Compare  Compare text in current window with text in next window."
  516. ;   (message "Compare not implemented yet."))  
  517. ;  ("Delete   Remove current window from the display."               delete-window)
  518. ;  ("Find     Find another buffer and change current window to it."  select-window)
  519. ;  ("Split    Divide current window Vertically or Horizontally."
  520. ;   (progn
  521. ;    (while (not (or (= opt ?h) (= opt ?v)))
  522. ;      (message "Split window: Horizontally Vertically ")
  523. ;      (setq opt (downcase (read-char))))
  524. ;    (if (= opt ?h) 
  525. ;        (call-interactively 'split-window-horizontally)
  526. ;        (call-interactively 'split-window-vertically))   ))
  527. ;  ("Other    Change to next window."                      other-window)
  528. ;  ("1        Make current window the only one visible."   (delete-other-windows))
  529. ;  ("+        Increase lines in current window."           (do-window-sizing))
  530. ;  ("-        Decrease lines in current window."           (do-window-sizing))
  531. ;  ("<        Increase columns in current window."         (do-window-sizing))
  532. ;  (">        Decrease columns in current window."         (do-window-sizing))))
  533. ;
  534. ;(defun do-window-sizing ()
  535. ; ;; is opt passed down?
  536. ; (while (or (= opt ?+) (= opt ?-) (= opt ?>) (= opt ?<))
  537. ;   (message "Change window size press '+', '-', '<', '>', or space to quit.")
  538. ;   (if (= opt ?+) (enlarge-window 1))
  539. ;   (if (= opt ?-) (shrink-window 1))
  540. ;   (if (= opt ?>) (enlarge-window-horizontally 1))
  541. ;   (if (= opt ?<) (shrink-window-horizontally 1))
  542. ;   (setq opt (read-char))))
  543. ;
  544. ;
  545. ;(def-menu 'buffer-menu
  546. ;  ""
  547. ;  "Displays menu of buffer commands to chose from"
  548. ; '(("Delete   Kill current buffer."               kill-buffer)
  549. ;  ("Edit     Edit another buffer."               switch-to-buffer)
  550. ;  ("File     Change to use File menu."           files-menu)
  551. ;  ("List     List current buffers and status."   list-buffers)
  552. ;  ("Other    Switch to buffer in other window."  switch-to-buffer-other-window)
  553. ;  ("Spell    Check spelling for current buffer." ispell-buffer)
  554. ;  ("Toggle   Toggle current buffer read-only status." toggle-read-only)
  555. ;  ("Window   Change to Windows menu."                 windows-menu)))
  556. ;
  557. ;(def-menu 'mode-menu 
  558. ;  "Mode"
  559. ;  "Displays menu of known major and minor modes to chose from"
  560. ; '(("1  [pfe-mode] Use PFE emulation and keyboard layout."   (pfe-mode))
  561. ;  ("A  [edit-abbrevs-mode] Major mode for editing list of abbrev definitions."
  562. ;     (edit-abbrevs-mode))
  563. ;  ("C  [c-mode] Major mode for editing C language source files."   (c-mode))
  564. ;  ("D  [normal-mode] Default to normal mode for current file."  (normal-mode))
  565. ;  ("F  [fortran-mode] Major mode for editing FORTRAN source files."  
  566. ;    (fortran-mode))
  567. ;  ("G  [emacs-lisp-mode] Major mode for editing GNU Emacs lisp source files."
  568. ;     (emacs-lisp-mode))
  569. ;  ("I  [lisp-interaction-mode] Major mode for typing/evaluating Lisp forms."
  570. ;     (lisp-interaction-mode))
  571. ;  ("L  [lisp-mode] Major mode for editing LISP code other than Emacs Lisp."
  572. ;    (lisp-mode))
  573. ;  ("O  [outline-mode] Major mode for editing outlines with selective display."
  574. ;     (outline-mode))
  575. ;  ("P  [picture-mode] Use quarter-plane screen model to edit."  (picture-mode))
  576. ;  ("T  [text-mode] Major mode for editing regular text files." (text-mode))
  577. ;  ("X  [tex-mode] Major mode for editing files of input for TeX or LaTeX."
  578. ;     (tex-mode))
  579. ;  ("Z  [fundamental-mode] Major mode not specialized for anything."
  580. ;    (fundamental-mode))))
  581. ;
  582. ;(def-menu 'align-menu 
  583. ;  "Align Option"
  584. ;  "Displays menu of region alignment commands to chose from:"
  585. ; '(("Center   Center all lines in region between left margin and fill column."
  586. ;     center-region)
  587. ;  ("Justify  Fill each paragraph between left margin and fill column."
  588. ;     (fill-region (point) (mark) t))
  589. ;  ("Left     Adjust lines to start in a specific column."
  590. ;    (progn (setq opt 
  591. ;                 (read-input "Align left at column: " (int-to-string left-margin)))
  592. ;           (setq opt (string-to-int opt))
  593. ;           (message (format "Align left at column %d." opt))
  594. ;           (indent-rigidly (point) (mark) opt)))
  595. ;  ("Right    Ajdust lines to end in a specific column if possible."
  596. ;     (progn (setq opt (read-input "Align right at column: " 
  597. ;                                  (int-to-string left-margin)))
  598. ;            (setq opt (string-to-int opt))
  599. ;            (message (format "Align right at column %d." opt))
  600. ;            (right-flush-region (point) (mark) opt)))
  601. ;  ("Tab      Indent each line in region relative to line above it." indent-region)
  602. ;  ))
  603. ;
  604.  
  605.  
  606.