mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
Added helpers and easy keybindings for HideShow mode
This commit is contained in:
21
helpers.el
21
helpers.el
@@ -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)))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
(flycheck-mode)
|
||||
(linum-mode t)
|
||||
(fci-mode)
|
||||
(hs-minor-mode 1)
|
||||
(auto-complete-mode)
|
||||
(subword-mode)
|
||||
(whitespace-mode)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
(flycheck-mode)
|
||||
(linum-mode t)
|
||||
(fci-mode)
|
||||
(hs-minor-mode 1)
|
||||
(auto-complete-mode)
|
||||
(whitespace-mode)
|
||||
(subword-mode)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
(flycheck-mode)
|
||||
(linum-mode t)
|
||||
(fci-mode)
|
||||
(hs-minor-mode 1)
|
||||
(auto-complete-mode)
|
||||
(subword-mode)
|
||||
(setq tab-width 2)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
(flyspell-prog-mode)
|
||||
(linum-mode t)
|
||||
(fci-mode)
|
||||
(hs-minor-mode 1)
|
||||
(auto-complete-mode)
|
||||
(subword-mode)
|
||||
(highlight-indentation-mode)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
(flycheck-mode)
|
||||
(linum-mode t)
|
||||
(fci-mode)
|
||||
(hs-minor-mode 1)
|
||||
(auto-complete-mode)
|
||||
(whitespace-mode)
|
||||
(subword-mode)
|
||||
|
||||
Reference in New Issue
Block a user