hide-show support enabled with python-mode.el

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

hide-show support enabled with python-mode.el

Andreas Röhler
Thanks for contribution!

Andreas

  User: aroehler
  Date: 09/09/29 12:18:50

  Modified:    packages/xemacs-packages/python-modes python-mode.el
Log:
Add support for HideShow

Mikhail Novikov <[hidden email]> delivered this patch at
https://code.launchpad.net/~freiksenet/python-mode/hide-show-support
It enables hs-minor-mode within python-mode.

Revision  Changes    Path
4.56      +21 -0     XEmacs/packages/xemacs-packages/python-modes/python-mode.el

Index: python-mode.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/python-modes/python-mode.el,v
retrieving revision 4.55
retrieving revision 4.56
diff -u -p -r4.55 -r4.56
--- python-mode.el 2009/09/28 10:44:10 4.55
+++ python-mode.el 2009/09/29 10:18:49 4.56
@@ -366,6 +366,18 @@ to select the appropriate python interpr
   :type 'boolean
   :group 'python)
 
+(defcustom py-hide-show-keywords '("class" "def" "elif" "else" "except"
+ "for" "if" "while" "finally" "try" "with")
+  "*Keywords used by hide-show"
+:type '(repeat string)
+:group 'python)
+
+(defcustom py-hide-show-hide-docstrings t
+  "*If doc strings shall be hidden"
+:type 'boolean
+:group 'python)
+
+
 
 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ;; NO USER DEFINABLE VARIABLES BEYOND THIS POINT
@@ -1216,6 +1228,15 @@ py-beep-if-tab-change\t\tring the bell i
     (if (fboundp 'imenu-add-to-menubar)
         (imenu-add-to-menubar (format "%s-%s" "IM" mode-name)))
     )
+
+  ;; Add support for HideShow
+  (add-to-list 'hs-special-modes-alist (list
+               'python-mode (concat (if py-hide-show-hide-docstrings "^\\s-*\"\"\"\\|" "") (mapconcat 'identity (mapcar #'(lambda (x) (concat "^\\s-*" x "\\>")) py-hide-show-keywords ) "\\|")) nil "#"
+               (lambda (arg)
+                 (py-goto-beyond-block)
+                 (skip-chars-backward " \t\n"))
+               nil))
+  
   ;; Run the mode hook.  Note that py-mode-hook is deprecated.
   (if python-mode-hook
       (run-hooks 'python-mode-hook)



_______________________________________________
XEmacs-CVS mailing list
[hidden email]
http://calypso.tux.org/mailman/listinfo/xemacs-cvs


_______________________________________________
Python-mode mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-mode