Guest User

Untitled

a guest
Jan 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. (require 'smalltalk-mode)
  2. (setq auto-mode-alist
  3. (append '(("\\.st\\'" . smalltalk-mode))
  4. auto-mode-alist))
  5.  
  6. (defun smalltalk-narrow-to-object ()
  7. ;;(interactive)
  8. (let* ((from (save-excursion (or (search-backward "! !" (point-min) t) (point-min))))
  9. (to (save-excursion (or (progn (search-forward "! !" (point-max) t)) (point-max)))))
  10. (narrow-to-region from to)))
  11.  
  12. (defun go-to-next-class ()
  13. (interactive)
  14. (widen)
  15. (let ((to (save-excursion (or (search-forward "! !" (point-max) t) (point-max)))))
  16. (when (not (= to (point-max)))
  17. (search-forward "! !" (point-max) t)
  18. (re-search-forward "^\\w" (point-max) t))
  19. (smalltalk-narrow-to-object)))
  20.  
  21. (defun go-to-prev-class ()
  22. (interactive)
  23. (widen)
  24. (let ((to (save-excursion (or (search-backward "! !" (point-min) t) (point-min)))))
  25. (when (not (= to (point-min)))
  26. (search-backward "! !" (point-min) t)
  27. (re-search-backward "\\w" (point-min) t))
  28. (smalltalk-narrow-to-object)))
  29.  
  30. (add-hook 'smalltalk-mode-hook
  31. (lambda ()
  32. (local-set-key (kbd "C-c n") 'go-to-next-class)
  33. (local-set-key (kbd "C-c p") 'go-to-prev-class)
  34. (local-set-key (kbd "C-c a") 'widen)))
Add Comment
Please, Sign In to add comment