;; Copyright (C) 2014, 2015 Free Software Foundation, Inc.
-;; Author: Artur Malabarba <bruce.connor.am@gmail.com>
+;; Author: Artur Malabarba <bruce.connor.am@>
+;; URL: https://github.com/Malabarba/speed-of-thought-lisp
;; Keywords: convenience, lisp
;; Package-Requires: ((emacs "24.1"))
-;; Version: 0
+;; Version: 1.1
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
\f
;;; Code:
-(eval-when-compile
- (require 'subr-x))
;;; Predicates
(defun sotlisp--auto-paired-p ()
("bc" . "forward-char -1")
("bfn" . "buffer-file-name")
("bl" . "buffer-list$")
+ ("blp" . "buffer-live-p ")
("bn" . "buffer-name")
("bod" . "beginning-of-defun")
("bol" . "forward-line 0$")
("k" . "kbd \"$\"")
("kb" . "kill-buffer")
("kn" . "kill-new ")
+ ("kp" . "keywordp ")
("l" . "lambda ($)")
("la" . "looking-at \"$\"")
("lap" . "looking-at-p \"$\"")
("ntr" . "narrow-to-region ")
("ow" . "other-window 1")
("p" . "point$")
+ ("pm" . "point-marker$")
("pa" . "point-max$")
("pg" . "plist-get ")
("pi" . "point-min$")
("s" . "setq ")
("sb" . "search-backward $ nil 'noerror")
("sbr" . "search-backward-regexp $ nil 'noerror")
- ("scb" . "skip-chars-backward \"$\r\n[:blank:]\"")
- ("scf" . "skip-chars-forward \"$\r\n[:blank:]\"")
+ ("scb" . "skip-chars-backward \"$\\r\\n[:blank:]\"")
+ ("scf" . "skip-chars-forward \"$\\r\\n[:blank:]\"")
("se" . "save-excursion")
("sf" . "search-forward $ nil 'noerror")
("sfr" . "search-forward-regexp $ nil 'noerror")
("wf" . "write-file ")
("wh" . "while ")
("wl" . "window-list nil 'nominibuffer")
+ ("we" . "window-end")
+ ("ws" . "window-start")
("wtb" . "with-temp-buffer")
("wtf" . "with-temp-file ")
)
\f
;;; The global minor-mode
-(defvar speed-of-thought-turn-on-hook '(sotlisp-turn-on-everywhere)
+(defvar speed-of-thought-turn-on-hook '()
"Hook run once when `speed-of-thought-mode' is enabled.
Note that `speed-of-thought-mode' is global, so this is not run
on every buffer.
See `sotlisp-turn-on-everywhere' for an example of what a
function in this hook should do.")
-(defvar speed-of-thought-turn-off-hook '(sotlisp-turn-off-everywhere)
+(defvar speed-of-thought-turn-off-hook '()
"Hook run once when `speed-of-thought-mode' is disabled.
Note that `speed-of-thought-mode' is global, so this is not run
on every buffer.
function in this hook should do.")
;;;###autoload
-(define-minor-mode speed-of-thought-mode nil nil nil nil
+(define-minor-mode speed-of-thought-mode
+ nil nil nil nil
:global t
(run-hooks (if speed-of-thought-mode
'speed-of-thought-turn-on-hook
'speed-of-thought-turn-off-hook)))
+;;;###autoload
+(defun speed-of-thought-hook-in (on off)
+ "Add functions ON and OFF to `speed-of-thought-mode' hooks.
+If `speed-of-thought-mode' is already on, call ON."
+ (add-hook 'speed-of-thought-turn-on-hook on)
+ (add-hook 'speed-of-thought-turn-off-hook off)
+ (when speed-of-thought-mode (funcall on)))
+
\f
;;; The local minor-mode
+(define-minor-mode sotlisp-mode
+ nil nil " SoT"
+ '(([M-return] . sotlisp-newline-and-parentheses)
+ ([C-return] . sotlisp-downlist-newline-and-parentheses)
+ ("\C-cf" . sotlisp-find-or-define-function)
+ ("\C-cv" . sotlisp-find-or-define-variable)))
+
(defun sotlisp-turn-on-everywhere ()
"Call-once function to turn on sotlisp everywhere.
Calls `sotlisp-mode' on all `emacs-lisp-mode' buffers, and sets
(with-current-buffer b
(when (derived-mode-p 'emacs-lisp-mode)
(sotlisp-mode 1))))
- (buffer-list)))
+ (buffer-list)))
(defun sotlisp-turn-off-everywhere ()
"Call-once function to turn off sotlisp everywhere.
(with-current-buffer b
(when (derived-mode-p 'emacs-lisp-mode)
(sotlisp-mode -1))))
- (buffer-list)))
+ (buffer-list)))
-(define-minor-mode sotlisp-mode nil nil " SoT"
- '(([M-return] . sotlisp-newline-and-parentheses)
- ([C-return] . sotlisp-downlist-newline-and-parentheses)
- ("\C-cf" . sotlisp-find-or-define-function)
- ("\C-cv" . sotlisp-find-or-define-variable)))
+(speed-of-thought-hook-in #'sotlisp-turn-on-everywhere #'sotlisp-turn-off-everywhere)
\f
;;; Commands
(ignore-errors (forward-sexp -1)
(looking-at-p "#'")))
(thing-at-point 'symbol)
- (if-let ((fcap (function-called-at-point)))
- (symbol-name fcap)
- (thing-at-point 'symbol))))
+ (let ((fcap (function-called-at-point)))
+ (if fcap (symbol-name fcap)
+ (thing-at-point 'symbol)))))
(defun sotlisp-find-or-define-function (&optional prefix)
"If symbol under point is a defined function, go to it, otherwise define it.
(provide 'sotlisp)
;;; sotlisp.el ends here
-