(python-mode): Added menu support, requires easymenu.

This commit is contained in:
Barry Warsaw 1996-07-29 21:05:05 +00:00
parent 8431733c07
commit 42f707f40f
1 changed files with 45 additions and 10 deletions

View File

@ -375,6 +375,38 @@ Currently-active file is at the head of the list.")
"\\)") "\\)")
"Regexp matching lines to not outdent after.") "Regexp matching lines to not outdent after.")
;; Menu definitions, only relevent if you have the easymenu.el package
;; (standard in the latest Emacs 19 and XEmacs 19 distributions).
(if (condition-case nil
(require 'easymenu)
(error nil))
(easy-menu-define
py-menu py-mode-map "Python Mode menu"
'("Python"
["Comment Out Region" comment-region (mark)]
["Uncomment Region" (comment-region (point) (mark) '(4)) (mark)]
"-"
["Mark current block" py-mark-block t]
["Mark current def" mark-python-def-or-class t]
["Mark current class" (mark-python-def-or-class t) t]
"-"
["Shift region left" py-shift-region-left (mark)]
["Shift region right" py-shift-region-right (mark)]
"-"
["Execute buffer" py-execute-buffer t]
["Execute region" py-execute-region (mark)]
["Start interpreter..." py-shell t]
"-"
["Go to start of block" py-goto-block-up t]
["Go to start of class" (beginning-of-python-def-or-class t) t]
["Move to end of class" (end-of-python-def-or-class t) t]
["Move to start of def" beginning-of-python-def-or-class t]
["Move to end of def" end-of-python-def-or-class t]
"-"
["Describe mode" py-describe-mode t]
)))
;;;###autoload ;;;###autoload
(defun python-mode () (defun python-mode ()
@ -391,12 +423,12 @@ COMMANDS
\\{py-mode-map} \\{py-mode-map}
VARIABLES VARIABLES
py-indent-offset\tindentation increment py-indent-offset\t\tindentation increment
py-block-comment-prefix\tcomment string used by py-comment-region py-block-comment-prefix\t\tcomment string used by comment-region
py-python-command\tshell command to invoke Python interpreter py-python-command\t\tshell command to invoke Python interpreter
py-scroll-process-buffer\talways scroll Python process buffer py-scroll-process-buffer\t\talways scroll Python process buffer
py-temp-directory\tdirectory used for temp files (if needed) py-temp-directory\t\tdirectory used for temp files (if needed)
py-beep-if-tab-change\tring the bell if tab-width is changed" py-beep-if-tab-change\t\tring the bell if tab-width is changed"
(interactive) (interactive)
(kill-all-local-variables) (kill-all-local-variables)
(set-syntax-table py-mode-syntax-table) (set-syntax-table py-mode-syntax-table)
@ -404,6 +436,9 @@ py-beep-if-tab-change\tring the bell if tab-width is changed"
mode-name "Python" mode-name "Python"
local-abbrev-table python-mode-abbrev-table) local-abbrev-table python-mode-abbrev-table)
(use-local-map py-mode-map) (use-local-map py-mode-map)
;; add the menu
(if py-menu
(easy-menu-add py-menu))
;; Emacs 19 requires this ;; Emacs 19 requires this
(if (or py-this-is-lucid-emacs-p py-this-is-emacs-19-p) (if (or py-this-is-lucid-emacs-p py-this-is-emacs-19-p)
(setq comment-multi-line nil)) (setq comment-multi-line nil))
@ -1518,7 +1553,7 @@ variable docs begin with `->'.
@VARIABLES @VARIABLES
py-indent-offset\tindentation increment py-indent-offset\tindentation increment
py-block-comment-prefix\tcomment string used by py-comment-region py-block-comment-prefix\tcomment string used by comment-region
py-python-command\tshell command to invoke Python interpreter py-python-command\tshell command to invoke Python interpreter
py-scroll-process-buffer\talways scroll Python process buffer py-scroll-process-buffer\talways scroll Python process buffer
@ -1675,11 +1710,11 @@ the block structure:
\\[py-mark-block]\t mark block of lines \\[py-mark-block]\t mark block of lines
\\[mark-python-def-or-class]\t mark smallest enclosing def \\[mark-python-def-or-class]\t mark smallest enclosing def
\\[universal-argument] \\[mark-python-def-or-class]\t mark smallest enclosing class \\[universal-argument] \\[mark-python-def-or-class]\t mark smallest enclosing class
\\[py-comment-region]\t comment out region of code \\[comment-region]\t comment out region of code
\\[universal-argument] \\[py-comment-region]\t uncomment region of code \\[universal-argument] \\[comment-region]\t uncomment region of code
%c:py-mark-block %c:py-mark-block
%c:mark-python-def-or-class %c:mark-python-def-or-class
%c:py-comment-region %c:comment-region
@MOVING POINT @MOVING POINT