X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=spray.el;h=c0d78085f2b36b214ec45e92481e1e3eda92189f;hb=128c54ad6c001fd85d19acaaa95af183873d7160;hp=5ce76ebe66704ffa66a7ad27b832cbf72b4b200d;hpb=72d7f30381c142e02f38dd1a97377623db3d27a5;p=spray
diff --git a/spray.el b/spray.el
index 5ce76eb..c0d7808 100644
--- a/spray.el
+++ b/spray.el
@@ -4,17 +4,16 @@
;; 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
-;; the Free Software Foundation; either version 2 of the License, or
+;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
-;;
+
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
-;;
+
;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+;; along with this program. If not, see .
;; Maintainer: Ian Kelling
;; Author: Ian Kelling
@@ -22,6 +21,7 @@
;; Created: 18 Jun 2014
;; Version: 0.0.2
;; URL: https://github.com/ian-kelling/spray
+;; Mailing list: https://lists.iankelling.org/listinfo/spray
;; Keywords: convenience
;;; Commentary:
@@ -99,6 +99,12 @@
:group 'spray
:type 'integer)
+(defcustom spray-save-point nil
+ "Set to true and then exiting spray mode will restore the point"
+ :group 'spray
+ :type 'boolean)
+
+
(defcustom spray-height 400
"Height of characters"
:group 'spray
@@ -124,7 +130,8 @@ decreasing by one for each subsequent word."
:type 'integer)
(defcustom spray-unsupported-minor-modes
- '(buffer-face-mode smartparens-mode highlight-symbol-mode)
+ '(buffer-face-mode smartparens-mode highlight-symbol-mode
+ column-number-mode)
"Minor modes to toggle off when in spray mode."
:group 'spray
:type '(list symbol))
@@ -137,7 +144,7 @@ decreasing by one for each subsequent word."
"Face for non-accent characters."
:group 'spray)
-(defface spray-base-face
+(defface spray-accent-face
'((t (:foreground "red" :inherit spray-base-face)))
"Face for accent character."
:group 'spray)
@@ -177,6 +184,7 @@ decreasing by one for each subsequent word."
(defvar spray--saved-cursor-type nil)
(defvar spray--saved-restriction nil)
(defvar spray--saved-minor-modes nil)
+(defvar spray--saved-point nil)
;; * utility functions
@@ -197,6 +205,7 @@ decreasing by one for each subsequent word."
(setq spray--base-overlay (make-overlay (point-min) (point-max))
spray--accent-overlay (make-overlay 0 0)
spray--saved-cursor-type cursor-type
+ spray--saved-point (point)
spray--saved-restriction (and (buffer-narrowed-p)
(cons (point-min) (point-max))))
(dolist (mode spray-unsupported-minor-modes)
@@ -221,6 +230,8 @@ decreasing by one for each subsequent word."
(cdr spray--saved-restriction))
(widen))
(setq cursor-type spray--saved-cursor-type)
+ (when (and spray-save-point spray--saved-point)
+ (goto-char spray--saved-point))
(dolist (mode spray--saved-minor-modes)
(funcall mode 1))
(setq spray--saved-minor-modes nil))))
@@ -236,11 +247,11 @@ decreasing by one for each subsequent word."
(len (+ (skip-chars-forward "^\s\t\nâ") (skip-chars-forward "â")))
(end (point))
(accent (+ beg (cl-case len
- ((1) 1)
- ((2 3 4 5) 2)
- ((6 7 8 9) 3)
- ((10 11 12 13) 4)
- (t 5)))))
+ ((1) 1)
+ ((2 3 4 5) 2)
+ ((6 7 8 9) 3)
+ ((10 11 12 13) 4)
+ (t 5)))))
;; this fairly obfuscated, using magic numbers to store state
;; it would be nice to sometime patch this so it is more readable.
;; for greater than 9 length, we display for twice as long
@@ -263,13 +274,11 @@ decreasing by one for each subsequent word."
(cond ((not (zerop spray--initial-delay))
(setq spray--initial-delay (1- spray--initial-delay)))
((not (zerop spray--delay))
- (setq spray--delay (1- spray--delay))
- (when (= spray--delay 2)
- (narrow-to-region (point) (point))))
+ (setq spray--delay (1- spray--delay)))
(t
(widen)
(if (eobp)
- (spray-mode -1)
+ (spray-quit)
(when (not (zerop spray--first-words))
(setq spray--initial-delay spray--first-words)
(setq spray--first-words (1- spray--first-words)))