[implementations-list] [PATCH] Sanitize the folding setup.

Štěpán Němec stepnem at gmail.com
Tue May 11 19:09:24 CEST 2010


Don't force `global-reveal-mode' upon users; this unbreaks at least Org and
Allout modes.

When we're at it, also
- don't use anonymous functions in hooks and key bindings (this sloppy
  practice should stay limited to user code)
- fix erroneous customize type of `vimpulse-fold-level'
- remove unused `vimpulse-hs-Open' definition
- don't call `hs-hide-all' interactively (makes no sense)
---
This patch doesn't improve the existing folding functionality, only
prevents it from breaking other Emacs modes.

I don't use Vimpulse folding, but testing didn't suggest any breakage
there (unless you consider preventing somewhat undeterministic behaviour
with Reveal mode on all the time a breakage).

 vimpulse-compatibility.el |   39 +++++++++++----------------------------
 vimpulse-dependencies.el  |    2 +-
 2 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/vimpulse-compatibility.el b/vimpulse-compatibility.el
index e40ceb3..210927f 100644
--- a/vimpulse-compatibility.el
+++ b/vimpulse-compatibility.el
@@ -279,36 +279,19 @@ Disable anyway if FORCE is t."
 
 ;;; Folding
 
-;; Almost all of this code is taken from extended-viper
-;; coded by Brad Beveridge (bradbev at gmail.com)
-;; - I changed the prefix of the custom functions to `vimpulse'
-;;   to avoid multiple prefixes
 (eval-after-load 'hideshow
   '(progn
-     (defun vimpulse-hs-Open ()
+     (defun vimpulse-za ()
        (interactive)
-       (hs-show-block)
-       (hs-hide-level -1))
-     (add-hook 'hs-minor-mode-hook
-               (lambda ()
-                 (call-interactively 'hs-hide-all)
-                 (define-key viper-vi-basic-map "za"
-                   (lambda ()
-                     (interactive)
-                     (hs-toggle-hiding)
-                     (hs-hide-level vimpulse-fold-level)))
-                 (define-key viper-vi-basic-map "za" 'hs-toggle-hiding)
-                 (define-key viper-vi-basic-map "zm" 'hs-hide-all)
-                 (define-key viper-vi-basic-map "zr" 'hs-show-all)
-                 (define-key viper-vi-basic-map "zo" 'hs-show-block)
-                 (define-key viper-vi-basic-map "zc" 'hs-hide-block)))))
-
-;; Load reveal.el if available
-(unless (featurep 'reveal)
-  (condition-case nil
-      (require 'reveal)
-    (error nil)))
-(when (fboundp 'global-reveal-mode)
-  (global-reveal-mode 1))
+       (hs-toggle-hiding)
+       (hs-hide-level vimpulse-fold-level))
+     (defun vimpulse-hs-setup ()
+       (hs-hide-all)
+       (define-key viper-vi-basic-map "za" 'vimpulse-za)
+       (define-key viper-vi-basic-map "zm" 'hs-hide-all)
+       (define-key viper-vi-basic-map "zr" 'hs-show-all)
+       (define-key viper-vi-basic-map "zo" 'hs-show-block)
+       (define-key viper-vi-basic-map "zc" 'hs-hide-block))
+     (add-hook 'hs-minor-mode-hook 'vimpulse-hs-setup)))
 
 (provide 'vimpulse-compatibility)
diff --git a/vimpulse-dependencies.el b/vimpulse-dependencies.el
index db90644..f37a2ec 100644
--- a/vimpulse-dependencies.el
+++ b/vimpulse-dependencies.el
@@ -102,7 +102,7 @@ Off by default."
 
 (defcustom vimpulse-fold-level 0
   "Default fold level."
-  :type  'boolean
+  :type  'integer
   :group 'vimpulse)
 
 ;; The secrets discovered from untold diggings among
-- 
1.7.1




More information about the implementations-list mailing list