Created
September 8, 2011 23:48
-
-
Save kidd/1205117 to your computer and use it in GitHub Desktop.
shortcuts to narrow buffers to classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'smalltalk-mode) | |
(setq auto-mode-alist | |
(append '(("\\.st\\'" . smalltalk-mode)) | |
auto-mode-alist)) | |
(defun smalltalk-narrow-to-object () | |
;;(interactive) | |
(let* ((from (save-excursion (or (search-backward "! !" (point-min) t) (point-min)))) | |
(to (save-excursion (or (progn (search-forward "! !" (point-max) t)) (point-max))))) | |
(narrow-to-region from to))) | |
(defun go-to-next-class () | |
(interactive) | |
(widen) | |
(let ((to (save-excursion (or (search-forward "! !" (point-max) t) (point-max))))) | |
(when (not (= to (point-max))) | |
(search-forward "! !" (point-max) t) | |
(re-search-forward "^\\w" (point-max) t)) | |
(smalltalk-narrow-to-object))) | |
(defun go-to-prev-class () | |
(interactive) | |
(widen) | |
(let ((to (save-excursion (or (search-backward "! !" (point-min) t) (point-min))))) | |
(when (not (= to (point-min))) | |
(search-backward "! !" (point-min) t) | |
(re-search-backward "\\w" (point-min) t)) | |
(smalltalk-narrow-to-object))) | |
(add-hook 'smalltalk-mode-hook | |
(lambda () | |
(local-set-key (kbd "C-c n") 'go-to-next-class) | |
(local-set-key (kbd "C-c p") 'go-to-prev-class) | |
(local-set-key (kbd "C-c a") 'widen))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment