Skip to content

Instantly share code, notes, and snippets.

@kidd kidd/jtalk.el
Created Sep 8, 2011

What would you like to do?
shortcuts to narrow buffers to classes
(require 'smalltalk-mode)
(setq auto-mode-alist
(append '(("\\.st\\'" . smalltalk-mode))
(defun smalltalk-narrow-to-object ()
(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 ()
(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))
(defun go-to-prev-class ()
(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))
(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
You can’t perform that action at this time.