Added helpers and easy keybindings for HideShow mode

This commit is contained in:
2014-08-10 13:44:48 +01:00
parent 583b9fd644
commit 4eebd1cc45
13 changed files with 41 additions and 4 deletions

View File

@@ -197,3 +197,24 @@ there's a region, all lines that region covers will be duplicated."
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil)))))))
;;
;; HideShow mode helpers
;; - from: http://www.emacswiki.org/emacs/HideShow
;;
(defun toggle-selective-display (column)
(interactive "P")
(set-selective-display
(or column
(unless selective-display
(1+ (current-column))))))
(defun toggle-hiding (column)
(interactive "P")
(if hs-minor-mode
(if (condition-case nil
(hs-toggle-hiding)
(error t))
(hs-show-all))
(toggle-selective-display column)))

View File

@@ -57,6 +57,10 @@
(global-set-key (kbd "C-c /") 'comment-or-uncomment-region-or-line)
(global-set-key (kbd "C-c C-/") 'comment-or-uncomment-region-or-line)
;; Custom HideShow toggles (via helpers.el)
(global-set-key (kbd "C-=") 'toggle-selective-display)
(global-set-key (kbd "C-\\") 'toggle-hiding)
(when (require 'auto-complete nil 'noerror)
(define-key ac-completing-map (kbd "RET") 'ac-complete)
(define-key ac-completing-map (kbd "C-m") 'ac-complete)

View File

@@ -7,6 +7,7 @@
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(whitespace-mode)

View File

@@ -3,6 +3,7 @@
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq css-indent-offset 2)

View File

@@ -4,6 +4,7 @@
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode))
(add-hook 'emacs-lisp-mode-hook 'customizations-for-emacs-lisp-mode)

View File

@@ -13,6 +13,7 @@
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(setq highlight-indentation-offset 2)
(highlight-indentation-mode)

View File

@@ -4,6 +4,7 @@
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(whitespace-mode)
(subword-mode)

View File

@@ -5,6 +5,7 @@
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq tab-width 2)

View File

@@ -4,6 +4,7 @@
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode))
(add-hook 'lisp-mode-hook 'customizations-for-lisp-mode)

View File

@@ -6,6 +6,7 @@
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(setq php-basic-offset 2)

View File

@@ -3,6 +3,7 @@
(flyspell-prog-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(subword-mode)
(highlight-indentation-mode)

View File

@@ -49,7 +49,7 @@
(setq ruby-use-encoding-map nil)
(setq whitespace-action (quote (auto-cleanup)))
(define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
(define-key ruby-mode-map (kbd "C-c C-h") 'hs-toggle-hiding)
(define-key ruby-mode-map (kbd "C-c C-h") 'toggle-hiding)
(define-key ruby-mode-map (kbd "C-c C-l") 'goto-line)
)
@@ -57,9 +57,11 @@
;; Set up hs-mode (HideShow) for Ruby
(add-to-list 'hs-special-modes-alist
'(ruby-mode
"\\(def \\|class\\|module\\|do\\)" "end" "#"
(lambda (arg) (ruby-end-of-block)) nil))
`(ruby-mode
,(rx (or "def" "class" "module" "{" "[")) ; Block start
,(rx (or "}" "]" "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
ruby-forward-sexp nil))
;; Workaround for missing method in ruby-mode.el
;; See: https://gist.github.com/1213051

View File

@@ -9,6 +9,7 @@
(flycheck-mode)
(linum-mode t)
(fci-mode)
(hs-minor-mode 1)
(auto-complete-mode)
(whitespace-mode)
(subword-mode)