Mercurial > cpython-lru_cache-weakref
diff Misc/python-mode.el @ 9905:6cf01eab05a3 legacy-trunk
(py-narrow-to-defun): New command (bound to C-x n d) which mimics the
standard narrow-to-defun but works with Python classes and methods.
With no arg, narrows to most enclosing def/method. With C-u arg,
narrows to most enclosing class.
| author | Barry Warsaw <barry@python.org> |
|---|---|
| date | Mon, 18 Jan 1999 21:49:39 +0000 |
| parents | 7bdef4bedd5c |
| children | 78059cf067de |
line wrap: on
line diff
--- a/Misc/python-mode.el Mon Jan 18 17:08:16 1999 +0000 +++ b/Misc/python-mode.el Mon Jan 18 21:49:39 1999 +0000 @@ -477,6 +477,9 @@ (define-key py-mode-map "\e\C-e" 'py-end-of-def-or-class) (define-key py-mode-map "\C-c-" 'py-up-exception) (define-key py-mode-map "\C-c=" 'py-down-exception) + ;; stuff that is `standard' but doesn't interface well with + ;; python-mode, which forces us to rebind to special commands + (define-key py-mode-map "\C-xnd" 'py-narrow-to-defun) ;; information (define-key py-mode-map "\C-c\C-b" 'py-submit-bug-report) (define-key py-mode-map "\C-c\C-v" 'py-version) @@ -1827,6 +1830,18 @@ (max comment-column (+ (current-column) (if (bolp) 0 1))) ))) +(defun py-narrow-to-defun (&optional class) + "Make text outside current defun invisible. +The defun visible is the one that contains point or follows point. +Optional CLASS is passed directly to `py-beginning-of-def-or-class'." + (interactive "P") + (save-excursion + (widen) + (py-end-of-def-or-class class) + (let ((end (point))) + (py-beginning-of-def-or-class class) + (narrow-to-region (point) end)))) + (defun py-shift-region (start end count) "Indent lines from START to END by COUNT spaces."
