Skip to content

Instantly share code, notes, and snippets.

@miyucy
Created October 27, 2009 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyucy/219197 to your computer and use it in GitHub Desktop.
Save miyucy/219197 to your computer and use it in GitHub Desktop.
;; vimのモードラインを読み込む
(defun load-vim-modeline-1 (matches)
(when matches
(dolist (match (split-string (match-string-no-properties 4)))
(when (or (string-match "^\\(tabstop\\|ts\\)=\\([0-9]+\\)$" match)
(string-match "^\\(shiftwidth\\|sw\\)=\\([0-9]+\\)$" match))
(setq tab-width (string-to-number (match-string-no-properties 2 match))))
(when (string-match "^\\(softtabstop\\|sts\\)=\\([0-9]+\\)$" match)
(setq tab-width (string-to-number (match-string-no-properties 2 match)))
(setq indent-tabs-mode nil))
(if (string-match "^\\(no\\)?\\(expandtab\\|et\\)$" match)
(if (string-equal "no" (match-string-no-properties 1 match))
(setq indent-tabs-mode t)
(setq indent-tabs-mode nil))))))
(defun load-vim-modeline ()
(save-excursion
(goto-char (point-min))
(load-vim-modeline-1 (re-search-forward "\\(.+\\)?[ \t]\\(vim?\\|ex\\): *?\\(set? \\)? *\\(.*\\) *?" (min 3000 (buffer-size)) t))
(goto-char (point-max))
(load-vim-modeline-1 (re-search-backward "\\(.+\\)?[ \t]\\(vim?\\|ex\\): *?\\(set? \\)? *\\(.*\\) *?" (min 3000 (buffer-size)) t))))
;; (remove-hook 'find-file-hook 'load-vim-modeline)
(add-hook 'find-file-hook 'load-vim-modeline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment