[Python-checkins] python/dist/src/Misc python-mode.el,4.11,4.12

bwarsaw@sourceforge.net bwarsaw@sourceforge.net
Mon, 22 Apr 2002 14:48:23 -0700


Update of /cvsroot/python/python/dist/src/Misc
In directory usw-pr-cvs1:/tmp/cvs-serv29250

Modified Files:
	python-mode.el 
Log Message:
Some contributions and ideas by Alexander Schmolck: add a keybinding
to call pychecker on the current file, add a face for pseudo
keywords self, None, True, False, and Ellipsis.  Specifically,

(py-pychecker-command, py-pychecker-command-args): New variables.

(py-pseudo-keyword-face): New face variable, defaulting to a copy of
font-lock-keyword-face.

(python-font-lock-keywords): Add an entry for self, None, True, False,
Ellipsis to be rendered in py-pseudo-keyword-face.

(py-pychecker-history): New variable.

(py-mode-map): Bind C-c C-w to py-pychecker-run.

(py-pychecker-run): New command.


Index: python-mode.el
===================================================================
RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v
retrieving revision 4.11
retrieving revision 4.12
diff -C2 -d -r4.11 -r4.12
*** python-mode.el	22 Apr 2002 17:15:19 -0000	4.11
--- python-mode.el	22 Apr 2002 21:48:20 -0000	4.12
***************
*** 287,290 ****
--- 287,302 ----
  (make-variable-buffer-local 'py-master-file)
  
+ (defcustom py-pychecker-command "pychecker"
+   "*Shell command used to run Pychecker."
+   :type 'string
+   :group 'python
+   :tag "Pychecker Command")
+ 
+ (defcustom py-pychecker-command-args '("--stdlib")
+   "*List of string arguments to be passed to pychecker."
+   :type '(repeat string)
+   :group 'python
+   :tag "Pychecker Command Args")
+ 
  
  
***************
*** 299,302 ****
--- 311,324 ----
  support for features needed by `python-mode'.")
  
+ ;; Face for None, True, False, self, and Ellipsis
+ (defvar py-pseudo-keyword-face 'py-pseudo-keyword-face
+   "Face for pseudo keywords in Python mode, like self, True, False, Ellipsis.")
+ (make-face 'py-pseudo-keyword-face)
+ 
+ (defun py-font-lock-mode-hook ()
+   (or (face-differs-from-default-p 'py-pseudo-keyword-face)
+       (copy-face 'font-lock-keyword-face 'py-pseudo-keyword-face)))
+ (add-hook 'font-lock-mode-hook 'py-font-lock-mode-hook)
+ 
  (defvar python-font-lock-keywords
    (let ((kw1 (mapconcat 'identity
***************
*** 328,331 ****
--- 350,356 ----
       '("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
         1 font-lock-function-name-face)
+      ;; pseudo-keywords
+      '("\\b\\(self\\|None\\|True\\|False\\|Ellipsis\\)\\b"
+        1 py-pseudo-keyword-face)
       ))
    "Additional expressions to highlight in Python mode.")
***************
*** 338,341 ****
--- 363,367 ----
  
  (defvar py-pdbtrack-is-tracking-p nil)
+ (defvar py-pychecker-history nil)
  
  
***************
*** 510,513 ****
--- 536,540 ----
    (define-key py-mode-map "\C-c\C-b" 'py-submit-bug-report)
    (define-key py-mode-map "\C-c\C-v" 'py-version)
+   (define-key py-mode-map "\C-c\C-w" 'py-pychecker-run)
    ;; shadow global bindings for newline-and-indent w/ the py- version.
    ;; BAW - this is extremely bad form, but I'm not going to change it
***************
*** 1425,1431 ****
  		(pop-to-buffer py-exception-buffer)))
  	  ))
!       ;; TBD: delete the buffer
!       )
!      )
      ;; Clean up after ourselves.
      (kill-buffer buf)))
--- 1452,1456 ----
  		(pop-to-buffer py-exception-buffer)))
  	  ))
!       ))
      ;; Clean up after ourselves.
      (kill-buffer buf)))
***************
*** 2610,2619 ****
  
  
! ;; Skip's python-help commands. The guts of this function is stolen
! ;; from XEmacs's symbol-near-point, but without the useless
! ;; regexp-quote call on the results, nor the interactive bit.  Also,
! ;; we've added the temporary syntax table setting, which Skip
! ;; originally had broken out into a separate function.  Note that
! ;; Emacs doesn't have the original function.
  (defun py-symbol-near-point ()
    "Return the first textual item to the nearest point."
--- 2635,2662 ----
  
  
! ;; Pychecker
! (defun py-pychecker-run (command)
!   "*Run pychecker (default on the file currently visited)."
!   (interactive
!    (let ((default
!            (format "%s %s %s" py-pychecker-command
! 		   (mapconcat 'identity py-pychecker-command-args " ")
! 		   (buffer-file-name))))
! 
!      (list
!       (read-shell-command "Run pychecker like this: "
!                           default
!                           py-pychecker-history))))
!   (save-some-buffers (not py-ask-about-save) nil)
!   (compile command))
! 
! 
! 
! ;; pydoc commands. The guts of this function is stolen from XEmacs's
! ;; symbol-near-point, but without the useless regexp-quote call on the
! ;; results, nor the interactive bit.  Also, we've added the temporary
! ;; syntax table setting, which Skip originally had broken out into a
! ;; separate function.  Note that Emacs doesn't have the original
! ;; function.
  (defun py-symbol-near-point ()
    "Return the first textual item to the nearest point."