Mercurial > dotfiles
annotate .elisp/paredit.el @ 94:9052c3801744
First stab at some menu items for the nose stuff.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 27 Apr 2009 21:52:04 -0500 |
parents | 9541f7e47514 |
children |
rev | line source |
---|---|
7
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1 ;;; -*- Mode: Emacs-Lisp; outline-regexp: "\n;;;;+" -*- |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 ;;;;;; Paredit: Parenthesis-Editing Minor Mode |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 ;;;;;; Version 20 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 ;;; This code is written by Taylor R. Campbell (except where explicitly |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 ;;; noted) and placed in the Public Domain. All warranties are |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 ;;; disclaimed. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
9 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 ;;; Add this to your .emacs after adding paredit.el to /path/to/elisp/: |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 ;;; (add-to-list 'load-path "/path/to/elisp/") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 ;;; (autoload 'paredit-mode "paredit" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
14 ;;; "Minor mode for pseudo-structurally editing Lisp code." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
15 ;;; t) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 ;;; (add-hook '...-mode-hook (lambda () (paredit-mode +1))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 ;;; Usually the ... will be lisp or scheme or both. Alternatively, you |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 ;;; can manually toggle this mode with M-x paredit-mode. Customization |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 ;;; of paredit can be accomplished with `eval-after-load': |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
22 ;;; (eval-after-load 'paredit |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
23 ;;; '(progn ...redefine keys, &c....)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 ;;; This should run in GNU Emacs 21 or later and XEmacs 21.5 or later. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 ;;; It is highly unlikely to work in earlier versions of GNU Emacs, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 ;;; it may have obscure problems in earlier versions of XEmacs due to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 ;;; the way its syntax parser reports conditions, as a result of which |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 ;;; the code that uses the syntax parser must mask *all* error |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 ;;; conditions, not just those generated by the syntax parser. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 ;;; This mode changes the keybindings for a number of simple keys, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 ;;; notably (, ), ", \, and ;. The bracket keys (round or square) are |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 ;;; defined to insert parenthesis pairs and move past the close, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 ;;; respectively; the double-quote key is multiplexed to do both, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 ;;; also insert an escape if within a string; backslashes prompt the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
37 ;;; user for the next character to input, because a lone backslash can |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
38 ;;; break structure inadvertently; and semicolons ensure that they do |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 ;;; not accidentally comment valid structure. (Use M-; to comment an |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 ;;; expression.) These all have their ordinary behaviour when inside |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 ;;; comments, and, outside comments, if truly necessary, you can insert |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 ;;; them literally with C-q. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 ;;; These keybindings are set up for my preference. One particular |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 ;;; preference which I've seen vary greatly from person to person is |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
46 ;;; whether the command to move past a closing delimiter ought to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 ;;; insert a newline. Since I find this behaviour to be more common |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 ;;; than that which inserts no newline, I have ) bound to it, and the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
49 ;;; more involved M-) to perform the less common action. This bothers |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
50 ;;; some users, though, and they prefer the other way around. This |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
51 ;;; code, which you can use `eval-after-load' to put in your .emacs, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
52 ;;; will exchange the bindings: |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
53 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
54 ;;; (define-key paredit-mode-map (kbd ")") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
55 ;;; 'paredit-close-parenthesis) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
56 ;;; (define-key paredit-mode-map (kbd "M-)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 ;;; 'paredit-close-parenthesis-and-newline) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 ;;; Paredit also changes the bindings of keys for deleting and killing, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 ;;; so that they will not destroy any S-expression structure by killing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 ;;; or deleting only one side of a bracket or quote pair. If the point |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 ;;; is on a closing bracket, DEL will move left over it; if it is on an |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 ;;; opening bracket, C-d will move right over it. Only if the point is |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 ;;; between a pair of brackets will C-d or DEL delete them, and in that |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 ;;; case it will delete both simultaneously. M-d and M-DEL kill words, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 ;;; but skip over any S-expression structure. C-k kills from the start |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 ;;; of the line, either to the line's end, if it contains only balanced |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 ;;; expressions; to the first closing bracket, if the point is within a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 ;;; form that ends on the line; or up to the end of the last expression |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 ;;; that starts on the line after the point. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 ;;; Automatic reindentation is performed as locally as possible, to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 ;;; ensure that Emacs does not interfere with custom indentation used |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 ;;; elsewhere in some S-expression. It is performed only by the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 ;;; advanced S-expression frobnication commands, and only on the forms |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
76 ;;; that were immediately operated upon (& their subforms). |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 ;;; This code is written for clarity, not efficiency. S-expressions |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 ;;; are frequently walked over redundantly. If you have problems with |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 ;;; some of the commands taking too long to execute, tell me, but first |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 ;;; make sure that what you're doing is reasonable: it is stylistically |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 ;;; bad to have huge, long, hideously nested code anyway. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 ;;; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 ;;; Questions, bug reports, comments, feature suggestions, &c., can be |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 ;;; addressed to the author via mail on the host mumble.net to campbell |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 ;;; or via IRC on irc.freenode.net in the #paredit channel under the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
87 ;;; nickname Riastradh. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
88 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
89 ;;; This assumes Unix-style LF line endings. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
90 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
91 (defconst paredit-version 20) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
92 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
93 (eval-and-compile |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
94 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
95 (defun paredit-xemacs-p () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
96 ;; No idea I got this definition from. Edward O'Connor (hober on |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
97 ;; IRC) suggested the current definition. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
98 ;; (and (boundp 'running-xemacs) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
99 ;; running-xemacs) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
100 (featurep 'xemacs)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
101 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
102 (defun paredit-gnu-emacs-p () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
103 (not (paredit-xemacs-p))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
104 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
105 (defmacro xcond (&rest clauses) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
106 "Exhaustive COND. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
107 Signal an error if no clause matches." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 `(cond ,@clauses |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
109 (t (error "XCOND lost.")))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
110 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
111 (defalias 'paredit-warn (if (fboundp 'warn) 'warn 'message)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
112 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
113 (defvar paredit-sexp-error-type |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
114 (with-temp-buffer |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
115 (insert "(") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
116 (condition-case condition |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
117 (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
118 (error (if (eq (car condition) 'error) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
119 (paredit-warn "%s%s%s%s" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
120 "Paredit is unable to discriminate" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
121 " S-expression parse errors from" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
122 " other errors. " |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
123 " This may cause obscure problems. " |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
124 " Please upgrade Emacs.")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
125 (car condition))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
126 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
127 (defmacro paredit-handle-sexp-errors (body &rest handler) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
128 `(condition-case () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
129 ,body |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
130 (,paredit-sexp-error-type ,@handler))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
131 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
132 (put 'paredit-handle-sexp-errors 'lisp-indent-function 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
133 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
134 (defmacro paredit-ignore-sexp-errors (&rest body) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
135 `(paredit-handle-sexp-errors (progn ,@body) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
136 nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
137 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
138 (put 'paredit-ignore-sexp-errors 'lisp-indent-function 0) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
139 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
140 nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
141 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 ;;;; Minor Mode Definition |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 (defvar paredit-mode-map (make-sparse-keymap) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 "Keymap for the paredit minor mode.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
146 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
147 (define-minor-mode paredit-mode |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
148 "Minor mode for pseudo-structurally editing Lisp code. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 \\<paredit-mode-map>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
150 :lighter " Paredit" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 ;; If we're enabling paredit-mode, the prefix to this code that |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
152 ;; DEFINE-MINOR-MODE inserts will have already set PAREDIT-MODE to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
153 ;; true. If this is the case, then first check the parentheses, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 ;; if there are any imbalanced ones we must inhibit the activation of |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 ;; paredit mode. We skip the check, though, if the user supplied a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 ;; prefix argument interactively. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 (if (and paredit-mode |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 (not current-prefix-arg)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
159 (if (not (fboundp 'check-parens)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
160 (paredit-warn "`check-parens' is not defined; %s" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
161 "be careful of malformed S-expressions.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 (condition-case condition |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
163 (check-parens) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
164 (error (setq paredit-mode nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
165 (signal (car condition) (cdr condition))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
166 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
167 ;;; Old functions from when there was a different mode for emacs -nw. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
168 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
169 (defun enable-paredit-mode () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
170 "Turn on pseudo-structural editing of Lisp code. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
171 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
172 Deprecated: use `paredit-mode' instead." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
173 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
174 (paredit-mode +1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
175 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
176 (defun disable-paredit-mode () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 "Turn off pseudo-structural editing of Lisp code. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
178 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 Deprecated: use `paredit-mode' instead." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
180 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
181 (paredit-mode -1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
182 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
183 (defvar paredit-backward-delete-key |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
184 (xcond ((paredit-xemacs-p) "BS") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 ((paredit-gnu-emacs-p) "DEL"))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
186 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
187 (defvar paredit-forward-delete-keys |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
188 (xcond ((paredit-xemacs-p) '("DEL")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
189 ((paredit-gnu-emacs-p) '("<delete>" "<deletechar>")))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
190 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
191 ;;;; Paredit Keys |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
192 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
193 ;;; Separating the definition and initialization of this variable |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
194 ;;; simplifies the development of paredit, since re-evaluating DEFVAR |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
195 ;;; forms doesn't actually do anything. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
196 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
197 (defvar paredit-commands nil |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
198 "List of paredit commands with their keys and examples.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
199 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
200 ;;; Each specifier is of the form: |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
201 ;;; (key[s] function (example-input example-output) ...) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
202 ;;; where key[s] is either a single string suitable for passing to KBD |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
203 ;;; or a list of such strings. Entries in this list may also just be |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
204 ;;; strings, in which case they are headings for the next entries. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
205 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
206 (progn (setq paredit-commands |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
207 `( |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
208 "Basic Insertion Commands" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
209 ("(" paredit-open-parenthesis |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
210 ("(a b |c d)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
211 "(a b (|) c d)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
212 ("(foo \"bar |baz\" quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
213 "(foo \"bar (|baz\" quux)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
214 (")" paredit-close-parenthesis-and-newline |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
215 ("(defun f (x| ))" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
216 "(defun f (x)\n |)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
217 ("; (Foo.|" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
218 "; (Foo.)|")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
219 ("M-)" paredit-close-parenthesis |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
220 ("(a b |c )" "(a b c)|") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
221 ("; Hello,| world!" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
222 "; Hello,)| world!")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
223 ("[" paredit-open-bracket |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
224 ("(a b |c d)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
225 "(a b [|] c d)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
226 ("(foo \"bar |baz\" quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
227 "(foo \"bar [baz\" quux)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
228 ("]" paredit-close-bracket |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
229 ("(define-key keymap [frob| ] 'frobnicate)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
230 "(define-key keymap [frob]| 'frobnicate)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
231 ("; [Bar.|" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
232 "; [Bar.]|")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
233 ("\"" paredit-doublequote |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
234 ("(frob grovel |full lexical)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
235 "(frob grovel \"|\" full lexical)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
236 ("(foo \"bar |baz\" quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
237 "(foo \"bar \\\"|baz\" quux)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
238 ("M-\"" paredit-meta-doublequote |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
239 ("(foo \"bar |baz\" quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
240 "(foo \"bar baz\"\n |quux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
241 ("(foo |(bar #\\x \"baz \\\\ quux\") zot)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
242 ,(concat "(foo \"|(bar #\\\\x \\\"baz \\\\" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
243 "\\\\ quux\\\")\" zot)"))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
244 ("\\" paredit-backslash |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
245 ("(string #|)\n ; Escaping character... (x)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
246 "(string #\\x|)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
247 ("\"foo|bar\"\n ; Escaping character... (\")" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
248 "\"foo\\\"|bar\"")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
249 (";" paredit-semicolon |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
250 ("|(frob grovel)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
251 ";|\n(frob grovel)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
252 ("(frob grovel) |" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
253 "(frob grovel) ;|")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
254 ("M-;" paredit-comment-dwim |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
255 ("(foo |bar) ; baz" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
256 "(foo bar) ; |baz") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
257 ("(frob grovel)|" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
258 "(frob grovel) ;|") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
259 (" (foo bar)\n|\n (baz quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
260 " (foo bar)\n ;; |\n (baz quux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
261 (" (foo bar) |(baz quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
262 " (foo bar)\n ;; |\n (baz quux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
263 ("|(defun hello-world ...)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
264 ";;; |\n(defun hello-world ...)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
265 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
266 ("C-j" paredit-newline |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
267 ("(let ((n (frobbotz))) |(display (+ n 1)\nport))" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
268 ,(concat "(let ((n (frobbotz)))" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
269 "\n |(display (+ n 1)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
270 "\n port))"))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
271 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
272 "Deleting & Killing" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
273 (("C-d" ,@paredit-forward-delete-keys) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
274 paredit-forward-delete |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
275 ("(quu|x \"zot\")" "(quu| \"zot\")") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
276 ("(quux |\"zot\")" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
277 "(quux \"|zot\")" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
278 "(quux \"|ot\")") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
279 ("(foo (|) bar)" "(foo | bar)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
280 ("|(foo bar)" "(|foo bar)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
281 (,paredit-backward-delete-key |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
282 paredit-backward-delete |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
283 ("(\"zot\" q|uux)" "(\"zot\" |uux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
284 ("(\"zot\"| quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
285 "(\"zot|\" quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
286 "(\"zo|\" quux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
287 ("(foo (|) bar)" "(foo | bar)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
288 ("(foo bar)|" "(foo bar|)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
289 ("C-k" paredit-kill |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
290 ("(foo bar)| ; Useless comment!" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
291 "(foo bar)|") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
292 ("(|foo bar) ; Useful comment!" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
293 "(|) ; Useful comment!") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
294 ("|(foo bar) ; Useless line!" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
295 "|") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
296 ("(foo \"|bar baz\"\n quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
297 "(foo \"|\"\n quux)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
298 ("M-d" paredit-forward-kill-word |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
299 ("|(foo bar) ; baz" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
300 "(| bar) ; baz" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
301 "(|) ; baz" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
302 "() ;|") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
303 (";;;| Frobnicate\n(defun frobnicate ...)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
304 ";;;|\n(defun frobnicate ...)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
305 ";;;\n(| frobnicate ...)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
306 (,(concat "M-" paredit-backward-delete-key) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
307 paredit-backward-kill-word |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
308 ("(foo bar) ; baz\n(quux)|" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
309 "(foo bar) ; baz\n(|)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
310 "(foo bar) ; |\n()" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
311 "(foo |) ; \n()" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
312 "(|) ; \n()")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
313 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
314 "Movement & Navigation" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
315 ("C-M-f" paredit-forward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
316 ("(foo |(bar baz) quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
317 "(foo (bar baz)| quux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
318 ("(foo (bar)|)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
319 "(foo (bar))|")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
320 ("C-M-b" paredit-backward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
321 ("(foo (bar baz)| quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
322 "(foo |(bar baz) quux)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
323 ("(|(foo) bar)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
324 "|((foo) bar)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
325 ;;;("C-M-u" backward-up-list) ; These two are built-in. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
326 ;;;("C-M-d" down-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
327 ("C-M-p" backward-down-list) ; Built-in, these are FORWARD- |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
328 ("C-M-n" up-list) ; & BACKWARD-LIST, which have |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
329 ; no need given C-M-f & C-M-b. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
330 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
331 "Depth-Changing Commands" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
332 ("M-(" paredit-wrap-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
333 ("(foo |bar baz)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
334 "(foo (|bar) baz)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
335 ("M-[" paredit-bracket-wrap-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
336 ("(foo |bar baz)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
337 "(foo [|bar] baz)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
338 ("M-s" paredit-splice-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
339 ("(foo (bar| baz) quux)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
340 "(foo bar| baz quux)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
341 (("M-<up>" "ESC <up>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
342 paredit-splice-sexp-killing-backward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
343 ("(foo (let ((x 5)) |(sqrt n)) bar)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
344 "(foo (sqrt n) bar)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
345 (("M-<down>" "ESC <down>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
346 paredit-splice-sexp-killing-forward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
347 ("(a (b c| d e) f)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
348 "(a b c f)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
349 ("M-r" paredit-raise-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
350 ("(dynamic-wind in (lambda () |body) out)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
351 "(dynamic-wind in |body out)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
352 "|body")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
353 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
354 "Barfage & Slurpage" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
355 (("C-)" "C-<right>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
356 paredit-forward-slurp-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
357 ("(foo (bar |baz) quux zot)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
358 "(foo (bar |baz quux) zot)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
359 ("(a b ((c| d)) e f)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
360 "(a b ((c| d) e) f)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
361 (("C-}" "C-<left>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
362 paredit-forward-barf-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
363 ("(foo (bar |baz quux) zot)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
364 "(foo (bar |baz) quux zot)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
365 (("C-(" "C-M-<left>" "ESC C-<left>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
366 paredit-backward-slurp-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
367 ("(foo bar (baz| quux) zot)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
368 "(foo (bar baz| quux) zot)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
369 ("(a b ((c| d)) e f)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
370 "(a (b (c| d)) e f)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 (("C-{" "C-M-<right>" "ESC C-<right>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
372 paredit-backward-barf-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
373 ("(foo (bar baz |quux) zot)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
374 "(foo bar (baz |quux) zot)")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
375 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
376 "Miscellaneous Commands" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
377 ("M-S" paredit-split-sexp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
378 ("(hello| world)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
379 "(hello)| (world)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
380 ("\"Hello, |world!\"" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
381 "\"Hello, \"| \"world!\"")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
382 ("M-J" paredit-join-sexps |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
383 ("(hello)| (world)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
384 "(hello| world)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
385 ("\"Hello, \"| \"world!\"" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
386 "\"Hello, |world!\"") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
387 ("hello-\n| world" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
388 "hello-|world")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
389 ("C-c C-M-l" paredit-recentre-on-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
390 )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
391 nil) ; end of PROGN |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
392 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
393 ;;;;; Command Examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
394 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
395 (eval-and-compile |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
396 (defmacro paredit-do-commands (vars string-case &rest body) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
397 (let ((spec (nth 0 vars)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
398 (keys (nth 1 vars)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
399 (fn (nth 2 vars)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
400 (examples (nth 3 vars))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
401 `(dolist (,spec paredit-commands) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
402 (if (stringp ,spec) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
403 ,string-case |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
404 (let ((,keys (let ((k (car ,spec))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
405 (cond ((stringp k) (list k)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
406 ((listp k) k) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
407 (t (error "Invalid paredit command %s." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
408 ,spec))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
409 (,fn (cadr ,spec)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
410 (,examples (cddr ,spec))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
411 ,@body))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
412 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
413 (put 'paredit-do-commands 'lisp-indent-function 2)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
414 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
415 (defun paredit-define-keys () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
416 (paredit-do-commands (spec keys fn examples) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
417 nil ; string case |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
418 (dolist (key keys) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
419 (define-key paredit-mode-map (read-kbd-macro key) fn)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
420 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
421 (defun paredit-function-documentation (fn) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
422 (let ((original-doc (get fn 'paredit-original-documentation)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
423 (doc (documentation fn 'function-documentation))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
424 (or original-doc |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
425 (progn (put fn 'paredit-original-documentation doc) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
426 doc)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
427 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
428 (defun paredit-annotate-mode-with-examples () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
429 (let ((contents |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
430 (list (paredit-function-documentation 'paredit-mode)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
431 (paredit-do-commands (spec keys fn examples) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
432 (push (concat "\n\n" spec "\n") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
433 contents) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
434 (let ((name (symbol-name fn))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
435 (if (string-match (symbol-name 'paredit-) name) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
436 (push (concat "\n\n\\[" name "]\t" name |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
437 (if examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
438 (mapconcat (lambda (example) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
439 (concat |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
440 "\n" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
441 (mapconcat 'identity |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
442 example |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
443 "\n --->\n") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
444 "\n")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
445 examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
446 "") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
447 "\n (no examples)\n")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
448 contents)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
449 (put 'paredit-mode 'function-documentation |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
450 (apply 'concat (reverse contents)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
451 ;; PUT returns the huge string we just constructed, which we don't |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
452 ;; want it to return. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
453 nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
454 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
455 (defun paredit-annotate-functions-with-examples () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
456 (paredit-do-commands (spec keys fn examples) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
457 nil ; string case |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
458 (put fn 'function-documentation |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
459 (concat (paredit-function-documentation fn) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
460 "\n\n\\<paredit-mode-map>\\[" (symbol-name fn) "]\n" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
461 (mapconcat (lambda (example) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
462 (concat "\n" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
463 (mapconcat 'identity |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
464 example |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
465 "\n ->\n") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
466 "\n")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
467 examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
468 ""))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
469 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
470 ;;;;; HTML Examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
471 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
472 (defun paredit-insert-html-examples () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
473 "Insert HTML for a paredit quick reference table." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
474 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
475 (let ((insert-lines (lambda (&rest lines) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
476 (mapc (lambda (line) (insert line) (newline)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
477 lines))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
478 (html-keys (lambda (keys) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
479 (mapconcat 'paredit-html-quote keys ", "))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
480 (html-example |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
481 (lambda (example) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
482 (concat "<table><tr><td><pre>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
483 (mapconcat 'paredit-html-quote |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
484 example |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
485 (concat "</pre></td></tr><tr><td>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
486 " --->" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
487 "</td></tr><tr><td><pre>")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
488 "</pre></td></tr></table>"))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
489 (firstp t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
490 (paredit-do-commands (spec keys fn examples) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
491 (progn (if (not firstp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
492 (insert "</table>\n") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
493 (setq firstp nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
494 (funcall insert-lines |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
495 (concat "<h3>" spec "</h3>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
496 "<table border=\"1\" cellpadding=\"1\">" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
497 " <tr>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
498 " <th>Command</th>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
499 " <th>Keys</th>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
500 " <th>Examples</th>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
501 " </tr>")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
502 (let ((name (symbol-name fn))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
503 (if (string-match (symbol-name 'paredit-) name) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
504 (funcall insert-lines |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
505 " <tr>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
506 (concat " <td><tt>" name "</tt></td>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
507 (concat " <td align=\"center\">" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
508 (funcall html-keys keys) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
509 "</td>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
510 (concat " <td>" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
511 (if examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
512 (mapconcat html-example examples |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
513 "<hr>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
514 "(no examples)") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
515 "</td>") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
516 " </tr>"))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
517 (insert "</table>\n")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
518 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
519 (defun paredit-html-quote (string) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
520 (with-temp-buffer |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
521 (dotimes (i (length string)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
522 (insert (let ((c (elt string i))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
523 (cond ((eq c ?\<) "<") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
524 ((eq c ?\>) ">") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
525 ((eq c ?\&) "&") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
526 ((eq c ?\') "'") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
527 ((eq c ?\") """) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
528 (t c))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
529 (buffer-string))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
530 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
531 ;;;; Delimiter Insertion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
532 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
533 (eval-and-compile |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
534 (defun paredit-conc-name (&rest strings) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
535 (intern (apply 'concat strings))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
536 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
537 (defmacro define-paredit-pair (open close name) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
538 `(progn |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
539 (defun ,(paredit-conc-name "paredit-open-" name) (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
540 ,(concat "Insert a balanced " name " pair. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
541 With a prefix argument N, put the closing " name " after N |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
542 S-expressions forward. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
543 If the region is active, `transient-mark-mode' is enabled, and the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
544 region's start and end fall in the same parenthesis depth, insert a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
545 " name " pair around the region. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
546 If in a string or a comment, insert a single " name ". |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
547 If in a character literal, do nothing. This prevents changing what was |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
548 in the character literal to a meaningful delimiter unintentionally.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
549 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
550 (cond ((or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
551 (paredit-in-comment-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
552 (insert ,open)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
553 ((not (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
554 (paredit-insert-pair n ,open ,close 'goto-char)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
555 (defun ,(paredit-conc-name "paredit-close-" name) () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
556 ,(concat "Move past one closing delimiter and reindent. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
557 \(Agnostic to the specific closing delimiter.) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
558 If in a string or comment, insert a single closing " name ". |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
559 If in a character literal, do nothing. This prevents changing what was |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
560 in the character literal to a meaningful delimiter unintentionally.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
561 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
562 (paredit-move-past-close ,close)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
563 (defun ,(paredit-conc-name "paredit-close-" name "-and-newline") () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
564 ,(concat "Move past one closing delimiter, add a newline," |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
565 " and reindent. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
566 If there was a margin comment after the closing delimiter, preserve it |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
567 on the same line.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
568 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
569 (paredit-move-past-close-and-newline ,close)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
570 (defun ,(paredit-conc-name "paredit-" name "-wrap-sexp") (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
571 ,(concat "Wrap a pair of " name " around a sexp") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
572 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
573 (paredit-wrap-sexp n ,open ,close))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
574 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
575 (define-paredit-pair ?\( ?\) "parenthesis") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
576 (define-paredit-pair ?\[ ?\] "bracket") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
577 (define-paredit-pair ?\{ ?\} "brace") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
578 (define-paredit-pair ?\< ?\> "brocket") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
579 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
580 (defun paredit-move-past-close (close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
581 (cond ((or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
582 (paredit-in-comment-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
583 (insert close)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
584 ((not (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
585 (paredit-move-past-close-and-reindent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
586 (paredit-blink-paren-match nil)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
587 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
588 (defun paredit-move-past-close-and-newline (close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
589 (cond ((or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
590 (paredit-in-comment-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
591 (insert close)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
592 (t (if (paredit-in-char-p) (forward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
593 (paredit-move-past-close-and-reindent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
594 (let ((comment.point (paredit-find-comment-on-line))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
595 (newline) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
596 (if comment.point |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
597 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
598 (forward-line -1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
599 (end-of-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
600 (indent-to (cdr comment.point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
601 (insert (car comment.point))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
602 (lisp-indent-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
603 (paredit-ignore-sexp-errors (indent-sexp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
604 (paredit-blink-paren-match t)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
605 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
606 (defun paredit-find-comment-on-line () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
607 "Find a margin comment on the current line. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
608 If such a comment exists, delete the comment (including all leading |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
609 whitespace) and return a cons whose car is the comment as a string |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
610 and whose cdr is the point of the comment's initial semicolon, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
611 relative to the start of the line." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
612 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
613 (catch 'return |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
614 (while t |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
615 (if (search-forward ";" (point-at-eol) t) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
616 (if (not (or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
617 (paredit-in-char-p))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
618 (let* ((start (progn (backward-char) ;before semicolon |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
619 (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
620 (comment (buffer-substring start |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
621 (point-at-eol)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
622 (paredit-skip-whitespace nil (point-at-bol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
623 (delete-region (point) (point-at-eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
624 (throw 'return |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
625 (cons comment (- start (point-at-bol)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
626 (throw 'return nil)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
627 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
628 (defun paredit-insert-pair (n open close forward) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
629 (let* ((regionp (and (paredit-region-active-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
630 (paredit-region-safe-for-insert-p))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
631 (end (and regionp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
632 (not n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
633 (prog1 (region-end) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
634 (goto-char (region-beginning)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
635 (let ((spacep (paredit-space-for-delimiter-p nil open))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
636 (if spacep (insert " ")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
637 (insert open) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
638 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
639 ;; Move past the desired region. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
640 (cond (n (funcall forward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
641 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
642 (forward-sexp (prefix-numeric-value n)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
643 (point)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
644 (regionp (funcall forward (+ end (if spacep 2 1))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
645 (insert close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
646 (if (paredit-space-for-delimiter-p t close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
647 (insert " ")))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
648 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
649 (defun paredit-region-safe-for-insert-p () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
650 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
651 (let ((beginning (region-beginning)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
652 (end (region-end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
653 (goto-char beginning) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
654 (let* ((beginning-state (paredit-current-parse-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
655 (end-state (parse-partial-sexp beginning end |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
656 nil nil beginning-state))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
657 (and (= (nth 0 beginning-state) ; 0. depth in parens |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
658 (nth 0 end-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
659 (eq (nth 3 beginning-state) ; 3. non-nil if inside a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
660 (nth 3 end-state)) ; string |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
661 (eq (nth 4 beginning-state) ; 4. comment status, yada |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
662 (nth 4 end-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
663 (eq (nth 5 beginning-state) ; 5. t if following char |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
664 (nth 5 end-state))))))) ; quote |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
665 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
666 (defun paredit-space-for-delimiter-p (endp delimiter) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
667 ;; If at the buffer limit, don't insert a space. If there is a word, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
668 ;; symbol, other quote, or non-matching parenthesis delimiter (i.e. a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
669 ;; close when want an open the string or an open when we want to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
670 ;; close the string), do insert a space. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
671 (and (not (if endp (eobp) (bobp))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
672 (memq (char-syntax (if endp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
673 (char-after) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
674 (char-before))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
675 (list ?w ?_ ?\" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
676 (let ((matching (matching-paren delimiter))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
677 (and matching (char-syntax matching))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
678 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
679 (defun paredit-move-past-close-and-reindent () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
680 (let ((orig (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
681 (up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
682 (if (catch 'return ; This CATCH returns T if it |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
683 (while t ; should delete leading spaces |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
684 (save-excursion ; and NIL if not. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
685 (let ((before-paren (1- (point)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
686 (back-to-indentation) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
687 (cond ((not (eq (point) before-paren)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
688 ;; Can't call PAREDIT-DELETE-LEADING-WHITESPACE |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
689 ;; here -- we must return from SAVE-EXCURSION |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
690 ;; first. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
691 (throw 'return t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
692 ((save-excursion (forward-line -1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
693 (end-of-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
694 (paredit-in-comment-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
695 ;; Moving the closing parenthesis any further |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
696 ;; would put it into a comment, so we just |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
697 ;; indent the closing parenthesis where it is |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
698 ;; and abort the loop, telling its continuation |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
699 ;; that no leading whitespace should be deleted. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
700 (lisp-indent-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
701 (throw 'return nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
702 (t (delete-indentation))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
703 (paredit-delete-leading-whitespace)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
704 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
705 (defun paredit-delete-leading-whitespace () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
706 ;; This assumes that we're on the closing parenthesis already. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
707 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
708 (backward-char) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
709 (while (let ((syn (char-syntax (char-before)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
710 (and (or (eq syn ?\ ) (eq syn ?-)) ; whitespace syntax |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
711 ;; The above line is a perfect example of why the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
712 ;; following test is necessary. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
713 (not (paredit-in-char-p (1- (point)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
714 (backward-delete-char 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
715 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
716 (defun paredit-blink-paren-match (another-line-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
717 (if (and blink-matching-paren |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
718 (or (not show-paren-mode) another-line-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
719 (paredit-ignore-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
720 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
721 (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
722 (forward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
723 ;; SHOW-PAREN-MODE inhibits any blinking, so we disable it |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
724 ;; locally here. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
725 (let ((show-paren-mode nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
726 (blink-matching-open)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
727 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
728 (defun paredit-doublequote (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
729 "Insert a pair of double-quotes. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
730 With a prefix argument N, wrap the following N S-expressions in |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
731 double-quotes, escaping intermediate characters if necessary. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
732 If the region is active, `transient-mark-mode' is enabled, and the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
733 region's start and end fall in the same parenthesis depth, insert a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
734 pair of double-quotes around the region, again escaping intermediate |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
735 characters if necessary. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
736 Inside a comment, insert a literal double-quote. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
737 At the end of a string, move past the closing double-quote. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
738 In the middle of a string, insert a backslash-escaped double-quote. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
739 If in a character literal, do nothing. This prevents accidentally |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
740 changing a what was in the character literal to become a meaningful |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
741 delimiter unintentionally." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
742 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
743 (cond ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
744 (if (eq (cdr (paredit-string-start+end-points)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
745 (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
746 (forward-char) ; We're on the closing quote. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
747 (insert ?\\ ?\" ))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
748 ((paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
749 (insert ?\" )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
750 ((not (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
751 (paredit-insert-pair n ?\" ?\" 'paredit-forward-for-quote)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
752 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
753 (defun paredit-meta-doublequote (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
754 "Move to the end of the string, insert a newline, and indent. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
755 If not in a string, act as `paredit-doublequote'; if no prefix argument |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
756 is specified and the region is not active or `transient-mark-mode' is |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
757 disabled, the default is to wrap one S-expression, however, not |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
758 zero." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
759 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
760 (if (not (paredit-in-string-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
761 (paredit-doublequote (or n |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
762 (and (not (paredit-region-active-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
763 1))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
764 (let ((start+end (paredit-string-start+end-points))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
765 (goto-char (1+ (cdr start+end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
766 (newline) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
767 (lisp-indent-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
768 (paredit-ignore-sexp-errors (indent-sexp))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
769 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
770 (defun paredit-forward-for-quote (end) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
771 (let ((state (paredit-current-parse-state))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
772 (while (< (point) end) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
773 (let ((new-state (parse-partial-sexp (point) (1+ (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
774 nil nil state))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
775 (if (paredit-in-string-p new-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
776 (if (not (paredit-in-string-escape-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
777 (setq state new-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
778 ;; Escape character: turn it into an escaped escape |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
779 ;; character by appending another backslash. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
780 (insert ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
781 ;; Now the point is after both escapes, and we want to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
782 ;; rescan from before the first one to after the second |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
783 ;; one. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
784 (setq state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
785 (parse-partial-sexp (- (point) 2) (point) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
786 nil nil state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
787 ;; Advance the end point, since we just inserted a new |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
788 ;; character. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
789 (setq end (1+ end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
790 ;; String: escape by inserting a backslash before the quote. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
791 (backward-char) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
792 (insert ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
793 ;; The point is now between the escape and the quote, and we |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
794 ;; want to rescan from before the escape to after the quote. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
795 (setq state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
796 (parse-partial-sexp (1- (point)) (1+ (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
797 nil nil state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
798 ;; Advance the end point for the same reason as above. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
799 (setq end (1+ end))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
800 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
801 ;;;; Escape Insertion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
802 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
803 (defun paredit-backslash () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
804 "Insert a backslash followed by a character to escape." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
805 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
806 (insert ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
807 ;; This funny conditional is necessary because PAREDIT-IN-COMMENT-P |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
808 ;; assumes that PAREDIT-IN-STRING-P already returned false; otherwise |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
809 ;; it may give erroneous answers. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
810 (if (or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
811 (not (paredit-in-comment-p))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
812 (let ((delp t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
813 (unwind-protect (setq delp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
814 (call-interactively 'paredit-escape)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
815 ;; We need this in an UNWIND-PROTECT so that the backlash is |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
816 ;; left in there *only* if PAREDIT-ESCAPE return NIL normally |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
817 ;; -- in any other case, such as the user hitting C-g or an |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
818 ;; error occurring, we must delete the backslash to avoid |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
819 ;; leaving a dangling escape. (This control structure is a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
820 ;; crock.) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
821 (if delp (backward-delete-char 1)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
822 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
823 ;;; This auxiliary interactive function returns true if the backslash |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
824 ;;; should be deleted and false if not. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
825 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
826 (defun paredit-escape (char) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
827 ;; I'm too lazy to figure out how to do this without a separate |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
828 ;; interactive function. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
829 (interactive "cEscaping character...") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
830 (if (eq char 127) ; The backslash was a typo, so |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
831 t ; the luser wants to delete it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
832 (insert char) ; (Is there a better way to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
833 nil)) ; express the rubout char? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
834 ; ?\^? works, but ugh...) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
835 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
836 ;;; The placement of this function in this file is totally random. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
837 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
838 (defun paredit-newline () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
839 "Insert a newline and indent it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
840 This is like `newline-and-indent', but it not only indents the line |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
841 that the point is on but also the S-expression following the point, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
842 if there is one. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
843 Move forward one character first if on an escaped character. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
844 If in a string, just insert a literal newline." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
845 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
846 (if (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
847 (newline) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
848 (if (and (not (paredit-in-comment-p)) (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
849 (forward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
850 (newline-and-indent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
851 ;; Indent the following S-expression, but don't signal an error if |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
852 ;; there's only a closing parenthesis after the point. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
853 (paredit-ignore-sexp-errors (indent-sexp)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
854 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
855 ;;;; Comment Insertion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
856 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
857 (defun paredit-semicolon (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
858 "Insert a semicolon, moving any code after the point to a new line. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
859 If in a string, comment, or character literal, insert just a literal |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
860 semicolon, and do not move anything to the next line. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
861 With a prefix argument N, insert N semicolons." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
862 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
863 (if (not (or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
864 (paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
865 (paredit-in-char-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
866 ;; No more code on the line after the point. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
867 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
868 (paredit-skip-whitespace t (point-at-eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
869 (or (eolp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
870 ;; Let the user prefix semicolons to existing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
871 ;; comments. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
872 (eq (char-after) ?\;))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
873 ;; Don't use NEWLINE-AND-INDENT, because that will delete all of |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
874 ;; the horizontal whitespace first, but we just want to move the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
875 ;; code following the point onto the next line while preserving |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
876 ;; the point on this line. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
877 ;++ Why indent only the line? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
878 (save-excursion (newline) (lisp-indent-line))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
879 (insert (make-string (if n (prefix-numeric-value n) 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
880 ?\; ))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
881 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
882 (defun paredit-comment-dwim (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
883 "Call the Lisp comment command you want (Do What I Mean). |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
884 This is like `comment-dwim', but it is specialized for Lisp editing. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
885 If transient mark mode is enabled and the mark is active, comment or |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
886 uncomment the selected region, depending on whether it was entirely |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
887 commented not not already. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
888 If there is already a comment on the current line, with no prefix |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
889 argument, indent to that comment; with a prefix argument, kill that |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
890 comment. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
891 Otherwise, insert a comment appropriate for the context and ensure that |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
892 any code following the comment is moved to the next line. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
893 At the top level, where indentation is calculated to be at column 0, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
894 insert a triple-semicolon comment; within code, where the indentation |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
895 is calculated to be non-zero, and on the line there is either no code |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
896 at all or code after the point, insert a double-semicolon comment; |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
897 and if the point is after all code on the line, insert a single- |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
898 semicolon margin comment at `comment-column'." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
899 (interactive "*P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
900 (require 'newcomment) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
901 (comment-normalize-vars) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
902 (cond ((paredit-region-active-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
903 (comment-or-uncomment-region (region-beginning) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
904 (region-end) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
905 arg)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
906 ((paredit-comment-on-line-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
907 (if arg |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
908 (comment-kill (if (integerp arg) arg nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
909 (comment-indent))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
910 (t (paredit-insert-comment)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
911 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
912 (defun paredit-comment-on-line-p () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
913 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
914 (beginning-of-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
915 (let ((comment-p nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
916 ;; Search forward for a comment beginning. If there is one, set |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
917 ;; COMMENT-P to true; if not, it will be nil. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
918 (while (progn (setq comment-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
919 (search-forward ";" (point-at-eol) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
920 ;; t -> no error |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
921 t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
922 (and comment-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
923 (or (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
924 (paredit-in-char-p (1- (point)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
925 (forward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
926 comment-p))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
927 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
928 (defun paredit-insert-comment () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
929 (let ((code-after-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
930 (save-excursion (paredit-skip-whitespace t (point-at-eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
931 (not (eolp)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
932 (code-before-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
933 (save-excursion (paredit-skip-whitespace nil (point-at-bol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
934 (not (bolp))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
935 (if (and (bolp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
936 ;; We have to use EQ 0 here and not ZEROP because ZEROP |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
937 ;; signals an error if its argument is non-numeric, but |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
938 ;; CALCULATE-LISP-INDENT may return nil. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
939 (eq (let ((indent (calculate-lisp-indent))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
940 (if (consp indent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
941 (car indent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
942 indent)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
943 0)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
944 ;; Top-level comment |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
945 (progn (if code-after-p (save-excursion (newline))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
946 (insert ";;; ")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
947 (if code-after-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
948 ;; Code comment |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
949 (progn (if code-before-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
950 ;++ Why NEWLINE-AND-INDENT here and not just |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
951 ;++ NEWLINE, or PAREDIT-NEWLINE? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
952 (newline-and-indent)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
953 (lisp-indent-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
954 (insert ";; ") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
955 ;; Move the following code. (NEWLINE-AND-INDENT will |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
956 ;; delete whitespace after the comment, though, so use |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
957 ;; NEWLINE & LISP-INDENT-LINE manually here.) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
958 (save-excursion (newline) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
959 (lisp-indent-line))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
960 ;; Margin comment |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
961 (progn (indent-to comment-column |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
962 1) ; 1 -> force one leading space |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
963 (insert ?\; )))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
964 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
965 ;;;; Character Deletion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
966 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
967 (defun paredit-forward-delete (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
968 "Delete a character forward or move forward over a delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
969 If on an opening S-expression delimiter, move forward into the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
970 S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
971 If on a closing S-expression delimiter, refuse to delete unless the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
972 S-expression is empty, in which case delete the whole S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
973 With a prefix argument, simply delete a character forward, without |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
974 regard for delimiter balancing." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
975 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
976 (cond ((or arg (eobp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
977 (delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
978 ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
979 (paredit-forward-delete-in-string)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
980 ((paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
981 ;++ What to do here? This could move a partial S-expression |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
982 ;++ into a comment and thereby invalidate the file's form, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
983 ;++ or move random text out of a comment. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
984 (delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
985 ((paredit-in-char-p) ; Escape -- delete both chars. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
986 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
987 (delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
988 ((eq (char-after) ?\\ ) ; ditto |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
989 (delete-char 2)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
990 ((let ((syn (char-syntax (char-after)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
991 (or (eq syn ?\( ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
992 (eq syn ?\" ))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
993 (forward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
994 ((and (not (paredit-in-char-p (1- (point)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
995 (eq (char-syntax (char-after)) ?\) ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
996 (eq (char-before) (matching-paren (char-after)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
997 (backward-delete-char 1) ; Empty list -- delete both |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
998 (delete-char 1)) ; delimiters. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
999 ;; Just delete a single character, if it's not a closing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1000 ;; parenthesis. (The character literal case is already |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1001 ;; handled by now.) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1002 ((not (eq (char-syntax (char-after)) ?\) )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1003 (delete-char 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1004 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1005 (defun paredit-forward-delete-in-string () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1006 (let ((start+end (paredit-string-start+end-points))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1007 (cond ((not (eq (point) (cdr start+end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1008 ;; If it's not the close-quote, it's safe to delete. But |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1009 ;; first handle the case that we're in a string escape. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1010 (cond ((paredit-in-string-escape-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1011 ;; We're right after the backslash, so backward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1012 ;; delete it before deleting the escaped character. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1013 (backward-delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1014 ((eq (char-after) ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1015 ;; If we're not in a string escape, but we are on a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1016 ;; backslash, it must start the escape for the next |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1017 ;; character, so delete the backslash before deleting |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1018 ;; the next character. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1019 (delete-char 1))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1020 (delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1021 ((eq (1- (point)) (car start+end)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1022 ;; If it is the close-quote, delete only if we're also right |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1023 ;; past the open-quote (i.e. it's empty), and then delete |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1024 ;; both quotes. Otherwise we refuse to delete it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1025 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1026 (delete-char 1))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1027 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1028 (defun paredit-backward-delete (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1029 "Delete a character backward or move backward over a delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1030 If on a closing S-expression delimiter, move backward into the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1031 S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1032 If on an opening S-expression delimiter, refuse to delete unless the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1033 S-expression is empty, in which case delete the whole S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1034 With a prefix argument, simply delete a character backward, without |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1035 regard for delimiter balancing." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1036 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1037 (cond ((or arg (bobp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1038 (backward-delete-char 1)) ;++ should this untabify? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1039 ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1040 (paredit-backward-delete-in-string)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1041 ((paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1042 (backward-delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1043 ((paredit-in-char-p) ; Escape -- delete both chars. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1044 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1045 (delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1046 ((paredit-in-char-p (1- (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1047 (backward-delete-char 2)) ; ditto |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1048 ((let ((syn (char-syntax (char-before)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1049 (or (eq syn ?\) ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1050 (eq syn ?\" ))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1051 (backward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1052 ((and (eq (char-syntax (char-before)) ?\( ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1053 (eq (char-after) (matching-paren (char-before)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1054 (backward-delete-char 1) ; Empty list -- delete both |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1055 (delete-char 1)) ; delimiters. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1056 ;; Delete it, unless it's an opening parenthesis. The case |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1057 ;; of character literals is already handled by now. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1058 ((not (eq (char-syntax (char-before)) ?\( )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1059 (backward-delete-char-untabify 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1060 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1061 (defun paredit-backward-delete-in-string () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1062 (let ((start+end (paredit-string-start+end-points))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1063 (cond ((not (eq (1- (point)) (car start+end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1064 ;; If it's not the open-quote, it's safe to delete. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1065 (if (paredit-in-string-escape-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1066 ;; If we're on a string escape, since we're about to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1067 ;; delete the backslash, we must first delete the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1068 ;; escaped char. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1069 (delete-char 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1070 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1071 (if (paredit-in-string-escape-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1072 ;; If, after deleting a character, we find ourselves in |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1073 ;; a string escape, we must have deleted the escaped |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1074 ;; character, and the backslash is behind the point, so |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1075 ;; backward delete it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1076 (backward-delete-char 1))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1077 ((eq (point) (cdr start+end)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1078 ;; If it is the open-quote, delete only if we're also right |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1079 ;; past the close-quote (i.e. it's empty), and then delete |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1080 ;; both quotes. Otherwise we refuse to delete it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1081 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1082 (delete-char 1))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1083 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1084 ;;;; Killing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1085 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1086 (defun paredit-kill (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1087 "Kill a line as if with `kill-line', but respecting delimiters. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1088 In a string, act exactly as `kill-line' but do not kill past the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1089 closing string delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1090 On a line with no S-expressions on it starting after the point or |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1091 within a comment, act exactly as `kill-line'. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1092 Otherwise, kill all S-expressions that start after the point." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1093 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1094 (cond (arg (kill-line)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1095 ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1096 (paredit-kill-line-in-string)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1097 ((or (paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1098 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1099 (paredit-skip-whitespace t (point-at-eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1100 (or (eq (char-after) ?\; ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1101 (eolp)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1102 ;** Be careful about trailing backslashes. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1103 (kill-line)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1104 (t (paredit-kill-sexps-on-line)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1105 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1106 (defun paredit-kill-line-in-string () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1107 (if (save-excursion (paredit-skip-whitespace t (point-at-eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1108 (eolp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1109 (kill-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1110 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1111 ;; Be careful not to split an escape sequence. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1112 (if (paredit-in-string-escape-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1113 (backward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1114 (let ((beginning (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1115 (while (not (or (eolp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1116 (eq (char-after) ?\" ))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1117 (forward-char) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1118 ;; Skip past escaped characters. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1119 (if (eq (char-before) ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1120 (forward-char))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1121 (kill-region beginning (point)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1122 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1123 (defun paredit-kill-sexps-on-line () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1124 (if (paredit-in-char-p) ; Move past the \ and prefix. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1125 (backward-char 2)) ; (# in Scheme/CL, ? in elisp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1126 (let ((beginning (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1127 (eol (point-at-eol))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1128 (let ((end-of-list-p (paredit-forward-sexps-to-kill beginning eol))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1129 ;; If we got to the end of the list and it's on the same line, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1130 ;; move backward past the closing delimiter before killing. (This |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1131 ;; allows something like killing the whitespace in ( ).) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1132 (if end-of-list-p (progn (up-list) (backward-char))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1133 (if kill-whole-line |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1134 (paredit-kill-sexps-on-whole-line beginning) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1135 (kill-region beginning |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1136 ;; If all of the S-expressions were on one line, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1137 ;; i.e. we're still on that line after moving past |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1138 ;; the last one, kill the whole line, including |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1139 ;; any comments; otherwise just kill to the end of |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1140 ;; the last S-expression we found. Be sure, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1141 ;; though, not to kill any closing parentheses. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1142 (if (and (not end-of-list-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1143 (eq (point-at-eol) eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1144 eol |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1145 (point))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1146 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1147 ;;; Please do not try to understand this code unless you have a VERY |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1148 ;;; good reason to do so. I gave up trying to figure it out well |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1149 ;;; enough to explain it, long ago. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1150 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1151 (defun paredit-forward-sexps-to-kill (beginning eol) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1152 (let ((end-of-list-p nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1153 (firstp t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1154 ;; Move to the end of the last S-expression that started on this |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1155 ;; line, or to the closing delimiter if the last S-expression in |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1156 ;; this list is on the line. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1157 (catch 'return |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1158 (while t |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1159 ;; This and the `kill-whole-line' business below fix a bug that |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1160 ;; inhibited any S-expression at the very end of the buffer |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1161 ;; (with no trailing newline) from being deleted. It's a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1162 ;; bizarre fix that I ought to document at some point, but I am |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1163 ;; too busy at the moment to do so. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1164 (if (and kill-whole-line (eobp)) (throw 'return nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1165 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1166 (paredit-handle-sexp-errors (forward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1167 (up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1168 (setq end-of-list-p (eq (point-at-eol) eol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1169 (throw 'return nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1170 (if (or (and (not firstp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1171 (not kill-whole-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1172 (eobp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1173 (paredit-handle-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1174 (progn (backward-sexp) nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1175 t) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1176 (not (eq (point-at-eol) eol))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1177 (throw 'return nil))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1178 (forward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1179 (if (and firstp |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1180 (not kill-whole-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1181 (eobp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1182 (throw 'return nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1183 (setq firstp nil))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1184 end-of-list-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1185 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1186 (defun paredit-kill-sexps-on-whole-line (beginning) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1187 (kill-region beginning |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1188 (or (save-excursion ; Delete trailing indentation... |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1189 (paredit-skip-whitespace t) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1190 (and (not (eq (char-after) ?\; )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1191 (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1192 ;; ...or just use the point past the newline, if |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1193 ;; we encounter a comment. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1194 (point-at-eol))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1195 (cond ((save-excursion (paredit-skip-whitespace nil (point-at-bol)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1196 (bolp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1197 ;; Nothing but indentation before the point, so indent it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1198 (lisp-indent-line)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1199 ((eobp) nil) ; Protect the CHAR-SYNTAX below against NIL. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1200 ;; Insert a space to avoid invalid joining if necessary. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1201 ((let ((syn-before (char-syntax (char-before))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1202 (syn-after (char-syntax (char-after)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1203 (or (and (eq syn-before ?\) ) ; Separate opposing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1204 (eq syn-after ?\( )) ; parentheses, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1205 (and (eq syn-before ?\" ) ; string delimiter |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1206 (eq syn-after ?\" )) ; pairs, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1207 (and (memq syn-before '(?_ ?w)) ; or word or symbol |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1208 (memq syn-after '(?_ ?w))))) ; constituents. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1209 (insert " ")))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1210 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1211 ;;;;; Killing Words |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1212 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1213 ;;; This is tricky and asymmetrical because backward parsing is |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1214 ;;; extraordinarily difficult or impossible, so we have to implement |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1215 ;;; killing in both directions by parsing forward. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1216 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1217 (defun paredit-forward-kill-word () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1218 "Kill a word forward, skipping over intervening delimiters." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1219 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1220 (let ((beginning (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1221 (skip-syntax-forward " -") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1222 (let* ((parse-state (paredit-current-parse-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1223 (state (paredit-kill-word-state parse-state 'char-after))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1224 (while (not (or (eobp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1225 (eq ?w (char-syntax (char-after))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1226 (setq parse-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1227 (progn (forward-char 1) (paredit-current-parse-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1228 ;; (parse-partial-sexp (point) (1+ (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1229 ;; nil nil parse-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1230 ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1231 (let* ((old-state state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1232 (new-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1233 (paredit-kill-word-state parse-state 'char-after))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1234 (cond ((not (eq old-state new-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1235 (setq parse-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1236 (paredit-kill-word-hack old-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1237 new-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1238 parse-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1239 (setq state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1240 (paredit-kill-word-state parse-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1241 'char-after)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1242 (setq beginning (point))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1243 (goto-char beginning) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1244 (kill-word 1))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1245 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1246 (defun paredit-backward-kill-word () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1247 "Kill a word backward, skipping over any intervening delimiters." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1248 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1249 (if (not (or (bobp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1250 (eq (char-syntax (char-before)) ?w))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1251 (let ((end (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1252 (backward-word 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1253 (forward-word 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1254 (goto-char (min end (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1255 (let* ((parse-state (paredit-current-parse-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1256 (state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1257 (paredit-kill-word-state parse-state 'char-before))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1258 (while (and (< (point) end) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1259 (progn |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1260 (setq parse-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1261 (parse-partial-sexp (point) (1+ (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1262 nil nil parse-state)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1263 (or (eq state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1264 (paredit-kill-word-state parse-state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1265 'char-before)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1266 (progn (backward-char 1) nil))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1267 (if (and (eq state 'comment) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1268 (eq ?\# (char-after (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1269 (eq ?\| (char-before (point)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1270 (backward-char 1))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1271 (backward-kill-word 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1272 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1273 ;;; Word-Killing Auxiliaries |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1274 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1275 (defun paredit-kill-word-state (parse-state adjacent-char-fn) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1276 (cond ((paredit-in-comment-p parse-state) 'comment) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1277 ((paredit-in-string-p parse-state) 'string) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1278 ((memq (char-syntax (funcall adjacent-char-fn)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1279 '(?\( ?\) )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1280 'delimiter) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1281 (t 'other))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1282 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1283 ;;; This optionally advances the point past any comment delimiters that |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1284 ;;; should probably not be touched, based on the last state change and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1285 ;;; the characters around the point. It returns a new parse state, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1286 ;;; starting from the PARSE-STATE parameter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1287 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1288 (defun paredit-kill-word-hack (old-state new-state parse-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1289 (cond ((and (not (eq old-state 'comment)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1290 (not (eq new-state 'comment)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1291 (not (paredit-in-string-escape-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1292 (eq ?\# (char-before)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1293 (eq ?\| (char-after))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1294 (forward-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1295 (paredit-current-parse-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1296 ;; (parse-partial-sexp (point) (1+ (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1297 ;; nil nil parse-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1298 ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1299 ((and (not (eq old-state 'comment)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1300 (eq new-state 'comment) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1301 (eq ?\; (char-before))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1302 (skip-chars-forward ";") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1303 (paredit-current-parse-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1304 ;; (parse-partial-sexp (point) (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1305 ;; (skip-chars-forward ";")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1306 ;; nil nil parse-state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1307 ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1308 (t parse-state))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1309 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1310 ;;;; Cursor and Screen Movement |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1311 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1312 (eval-and-compile |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1313 (defmacro defun-saving-mark (name bvl doc &rest body) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1314 `(defun ,name ,bvl |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1315 ,doc |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1316 ,(xcond ((paredit-xemacs-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1317 '(interactive "_")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1318 ((paredit-gnu-emacs-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1319 '(interactive))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1320 ,@body))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1321 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1322 (defun-saving-mark paredit-forward () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1323 "Move forward an S-expression, or up an S-expression forward. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1324 If there are no more S-expressions in this one before the closing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1325 delimiter, move past that closing delimiter; otherwise, move forward |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1326 past the S-expression following the point." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1327 (paredit-handle-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1328 (forward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1329 ;++ Is it necessary to use UP-LIST and not just FORWARD-CHAR? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1330 (if (paredit-in-string-p) (forward-char) (up-list)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1331 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1332 (defun-saving-mark paredit-backward () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1333 "Move backward an S-expression, or up an S-expression backward. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1334 If there are no more S-expressions in this one before the opening |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1335 delimiter, move past that opening delimiter backward; otherwise, move |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1336 move backward past the S-expression preceding the point." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1337 (paredit-handle-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1338 (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1339 (if (paredit-in-string-p) (backward-char) (backward-up-list)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1340 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1341 ;;; Why is this not in lisp.el? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1342 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1343 (defun backward-down-list (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1344 "Move backward and descend into one level of parentheses. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1345 With ARG, do this that many times. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1346 A negative argument means move forward but still descend a level." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1347 (interactive "p") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1348 (down-list (- (or arg 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1349 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1350 ;;; Thanks to Marco Baringer for suggesting & writing this function. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1351 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1352 (defun paredit-recentre-on-sexp (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1353 "Recentre the screen on the S-expression following the point. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1354 With a prefix argument N, encompass all N S-expressions forward." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1355 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1356 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1357 (forward-sexp n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1358 (let ((end-point (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1359 (backward-sexp n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1360 (let* ((start-point (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1361 (start-line (count-lines (point-min) (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1362 (lines-on-sexps (count-lines start-point end-point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1363 (goto-line (+ start-line (/ lines-on-sexps 2))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1364 (recenter))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1365 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1366 ;;;; Depth-Changing Commands: Wrapping, Splicing, & Raising |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1367 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1368 (defun paredit-wrap-sexp (&optional n open close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1369 "Wrap the following S-expression in a list. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1370 If a prefix argument N is given, wrap N S-expressions. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1371 Automatically indent the newly wrapped S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1372 As a special case, if the point is at the end of a list, simply insert |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1373 a pair of parentheses, rather than insert a lone opening parenthesis |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1374 and then signal an error, in the interest of preserving structure." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1375 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1376 (let ((open (or open ?\()) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1377 (close (or close ?\)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1378 (paredit-handle-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1379 (paredit-insert-pair (or n |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1380 (and (not (paredit-region-active-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1381 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1382 open close |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1383 'goto-char) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1384 (insert close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1385 (backward-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1386 (save-excursion (backward-up-list) (indent-sexp)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1387 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1388 ;;; Thanks to Marco Baringer for the suggestion of a prefix argument |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1389 ;;; for PAREDIT-SPLICE-SEXP. (I, Taylor R. Campbell, however, still |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1390 ;;; implemented it, in case any of you lawyer-folk get confused by the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1391 ;;; remark in the top of the file about explicitly noting code written |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1392 ;;; by other people.) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1393 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1394 (defun paredit-splice-sexp (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1395 "Splice the list that the point is on by removing its delimiters. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1396 With a prefix argument as in `C-u', kill all S-expressions backward in |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1397 the current list before splicing all S-expressions forward into the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1398 enclosing list. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1399 With two prefix arguments as in `C-u C-u', kill all S-expressions |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1400 forward in the current list before splicing all S-expressions |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1401 backward into the enclosing list. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1402 With a numerical prefix argument N, kill N S-expressions backward in |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1403 the current list before splicing the remaining S-expressions into the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1404 enclosing list. If N is negative, kill forward. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1405 This always creates a new entry on the kill ring." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1406 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1407 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1408 (paredit-kill-surrounding-sexps-for-splice arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1409 (backward-up-list) ; Go up to the beginning... |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1410 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1411 (forward-sexp) ; Go forward an expression, to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1412 (backward-delete-char 1)) ; delete the end delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1413 (delete-char 1) ; ...to delete the open char. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1414 (paredit-ignore-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1415 (backward-up-list) ; Reindent, now that the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1416 (indent-sexp)))) ; structure has changed. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1417 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1418 (defun paredit-kill-surrounding-sexps-for-splice (arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1419 (cond ((paredit-in-string-p) (error "Splicing illegal in strings.")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1420 ((or (not arg) (eq arg 0)) nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1421 ((or (numberp arg) (eq arg '-)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1422 ;; Kill ARG S-expressions before/after the point by saving |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1423 ;; the point, moving across them, and killing the region. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1424 (let* ((arg (if (eq arg '-) -1 arg)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1425 (saved (paredit-point-at-sexp-boundary (- arg)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1426 (paredit-ignore-sexp-errors (backward-sexp arg)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1427 (kill-region-new saved (point)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1428 ((consp arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1429 (let ((v (car arg))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1430 (if (= v 4) ; one prefix argument |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1431 ;; Move backward until we hit the open paren; then |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1432 ;; kill that selected region. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1433 (let ((end (paredit-point-at-sexp-start))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1434 (paredit-ignore-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1435 (while (not (bobp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1436 (backward-sexp))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1437 (kill-region-new (point) end)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1438 ;; Move forward until we hit the close paren; then |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1439 ;; kill that selected region. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1440 (let ((beginning (paredit-point-at-sexp-end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1441 (paredit-ignore-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1442 (while (not (eobp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1443 (forward-sexp))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1444 (kill-region-new beginning (point)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1445 (t (error "Bizarre prefix argument: %s" arg)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1446 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1447 (defun paredit-splice-sexp-killing-backward (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1448 "Splice the list the point is on by removing its delimiters, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1449 also kill all S-expressions before the point in the current list. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1450 With a prefix argument N, kill only the preceding N S-expressions." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1451 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1452 (paredit-splice-sexp (if n |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1453 (prefix-numeric-value n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1454 '(4)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1455 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1456 (defun paredit-splice-sexp-killing-forward (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1457 "Splice the list the point is on by removing its delimiters, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1458 also kill all S-expressions after the point in the current list. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1459 With a prefix argument N, kill only the following N S-expressions." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1460 (interactive "P") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1461 (paredit-splice-sexp (if n |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1462 (- (prefix-numeric-value n)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1463 '(16)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1464 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1465 (defun paredit-raise-sexp (&optional n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1466 "Raise the following S-expression in a tree, deleting its siblings. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1467 With a prefix argument N, raise the following N S-expressions. If N |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1468 is negative, raise the preceding N S-expressions." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1469 (interactive "p") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1470 ;; Select the S-expressions we want to raise in a buffer substring. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1471 (let* ((bound (save-excursion (forward-sexp n) (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1472 (sexps (save-excursion ;++ Is this necessary? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1473 (if (and n (< n 0)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1474 (buffer-substring bound |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1475 (paredit-point-at-sexp-end)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1476 (buffer-substring (paredit-point-at-sexp-start) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1477 bound))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1478 ;; Move up to the list we're raising those S-expressions out of and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1479 ;; delete it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1480 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1481 (delete-region (point) (save-excursion (forward-sexp) (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1482 (save-excursion (insert sexps)) ; Insert & reindent the sexps. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1483 (save-excursion (let ((n (abs (or n 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1484 (while (> n 0) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1485 (paredit-forward-and-indent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1486 (setq n (1- n))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1487 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1488 ;;;; Slurpage & Barfage |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1489 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1490 (defun paredit-forward-slurp-sexp () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1491 "Add the S-expression following the current list into that list |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1492 by moving the closing delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1493 Automatically reindent the newly slurped S-expression with respect to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1494 its new enclosing form. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1495 If in a string, move the opening double-quote forward by one |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1496 S-expression and escape any intervening characters as necessary, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1497 without altering any indentation or formatting." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1498 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1499 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1500 (cond ((or (paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1501 (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1502 (error "Invalid context for slurpage")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1503 ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1504 (paredit-forward-slurp-into-string)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1505 (t |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1506 (paredit-forward-slurp-into-list))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1507 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1508 (defun paredit-forward-slurp-into-list () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1509 (up-list) ; Up to the end of the list to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1510 (let ((close (char-before))) ; save and delete the closing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1511 (backward-delete-char 1) ; delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1512 (catch 'return ; Go to the end of the desired |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1513 (while t ; S-expression, going up a |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1514 (paredit-handle-sexp-errors ; list if it's not in this, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1515 (progn (paredit-forward-and-indent) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1516 (throw 'return nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1517 (insert close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1518 (up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1519 (setq close (char-before)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1520 (backward-delete-char 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1521 (insert close))) ; to insert that delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1522 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1523 (defun paredit-forward-slurp-into-string () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1524 (goto-char (1+ (cdr (paredit-string-start+end-points)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1525 ;; Signal any errors that we might get first, before mucking with the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1526 ;; buffer's contents. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1527 (save-excursion (forward-sexp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1528 (let ((close (char-before))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1529 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1530 (paredit-forward-for-quote (save-excursion (forward-sexp) (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1531 (insert close))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1532 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1533 (defun paredit-forward-barf-sexp () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1534 "Remove the last S-expression in the current list from that list |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1535 by moving the closing delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1536 Automatically reindent the newly barfed S-expression with respect to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1537 its new enclosing form." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1538 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1539 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1540 (up-list) ; Up to the end of the list to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1541 (let ((close (char-before))) ; save and delete the closing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1542 (backward-delete-char 1) ; delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1543 (paredit-ignore-sexp-errors ; Go back to where we want to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1544 (backward-sexp)) ; insert the delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1545 (paredit-skip-whitespace nil) ; Skip leading whitespace. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1546 (cond ((bobp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1547 (error "Barfing all subexpressions with no open-paren?")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1548 ((paredit-in-comment-p) ; Don't put the close-paren in |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1549 (newline-and-indent))) ; a comment. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1550 (insert close)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1551 ;; Reindent all of the newly barfed S-expressions. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1552 (paredit-forward-and-indent))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1553 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1554 (defun paredit-backward-slurp-sexp () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1555 "Add the S-expression preceding the current list into that list |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1556 by moving the closing delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1557 Automatically reindent the whole form into which new S-expression was |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1558 slurped. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1559 If in a string, move the opening double-quote backward by one |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1560 S-expression and escape any intervening characters as necessary, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1561 without altering any indentation or formatting." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1562 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1563 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1564 (cond ((or (paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1565 (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1566 (error "Invalid context for slurpage")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1567 ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1568 (paredit-backward-slurp-into-string)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1569 (t |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1570 (paredit-backward-slurp-into-list))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1571 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1572 (defun paredit-backward-slurp-into-list () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1573 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1574 (let ((open (char-after))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1575 (delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1576 (catch 'return |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1577 (while t |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1578 (paredit-handle-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1579 (progn (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1580 (throw 'return nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1581 (insert open) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1582 (backward-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1583 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1584 (setq open (char-after)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1585 (delete-char 1)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1586 (insert open)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1587 ;; Reindent the line at the beginning of wherever we inserted the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1588 ;; opening parenthesis, and then indent the whole S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1589 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1590 (lisp-indent-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1591 (indent-sexp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1592 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1593 (defun paredit-backward-slurp-into-string () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1594 (goto-char (car (paredit-string-start+end-points))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1595 ;; Signal any errors that we might get first, before mucking with the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1596 ;; buffer's contents. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1597 (save-excursion (backward-sexp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1598 (let ((open (char-after)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1599 (target (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1600 (message "open = %S" open) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1601 (delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1602 (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1603 (insert open) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1604 (paredit-forward-for-quote target))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1605 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1606 (defun paredit-backward-barf-sexp () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1607 "Remove the first S-expression in the current list from that list |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1608 by moving the closing delimiter. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1609 Automatically reindent the barfed S-expression and the form from which |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1610 it was barfed." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1611 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1612 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1613 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1614 (let ((open (char-after))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1615 (delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1616 (paredit-ignore-sexp-errors |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1617 (paredit-forward-and-indent)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1618 (while (progn (paredit-skip-whitespace t) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1619 (eq (char-after) ?\; )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1620 (forward-line 1)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1621 (if (eobp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1622 (error |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1623 "Barfing all subexpressions with no close-paren?")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1624 ;** Don't use `insert' here. Consider, e.g., barfing from |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1625 ;** (foo|) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1626 ;** and how `save-excursion' works. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1627 (insert-before-markers open)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1628 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1629 (lisp-indent-line) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1630 (indent-sexp))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1631 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1632 ;;;; Splitting & Joining |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1633 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1634 (defun paredit-split-sexp () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1635 "Split the list or string the point is on into two." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1636 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1637 (cond ((paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1638 (insert "\"") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1639 (save-excursion (insert " \""))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1640 ((or (paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1641 (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1642 (error "Invalid context for `paredit-split-sexp'")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1643 (t (let ((open (save-excursion (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1644 (char-after))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1645 (close (save-excursion (up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1646 (char-before)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1647 (delete-horizontal-space) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1648 (insert close) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1649 (save-excursion (insert ?\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1650 (insert open) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1651 (backward-char) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1652 (indent-sexp)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1653 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1654 (defun paredit-join-sexps () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1655 "Join the S-expressions adjacent on either side of the point. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1656 Both must be lists, strings, or atoms; error if there is a mismatch." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1657 (interactive) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1658 ;++ How ought this to handle comments intervening symbols or strings? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1659 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1660 (if (or (paredit-in-comment-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1661 (paredit-in-string-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1662 (paredit-in-char-p)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1663 (error "Invalid context in which to join S-expressions.") |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1664 (let ((left-point (save-excursion (paredit-point-at-sexp-end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1665 (right-point (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1666 (paredit-point-at-sexp-start)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1667 (let ((left-char (char-before left-point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1668 (right-char (char-after right-point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1669 (let ((left-syntax (char-syntax left-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1670 (right-syntax (char-syntax right-char))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1671 (cond ((>= left-point right-point) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1672 (error "Can't join a datum with itself.")) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1673 ((and (eq left-syntax ?\) ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1674 (eq right-syntax ?\( ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1675 (eq left-char (matching-paren right-char)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1676 (eq right-char (matching-paren left-char))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1677 ;; Leave intermediate formatting alone. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1678 (goto-char right-point) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1679 (delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1680 (goto-char left-point) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1681 (backward-delete-char 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1682 (backward-up-list) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1683 (indent-sexp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1684 ((and (eq left-syntax ?\" ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1685 (eq right-syntax ?\" )) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1686 ;; Delete any intermediate formatting. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1687 (delete-region (1- left-point) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1688 (1+ right-point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1689 ((and (memq left-syntax '(?w ?_)) ; Word or symbol |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1690 (memq right-syntax '(?w ?_))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1691 (delete-region left-point right-point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1692 (t |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1693 (error "Mismatched S-expressions to join."))))))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1694 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1695 ;;;; Utilities |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1696 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1697 (defun paredit-in-string-escape-p () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1698 "True if the point is on a character escape of a string. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1699 This is true only if the character is preceded by an odd number of |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1700 backslashes. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1701 This assumes that `paredit-in-string-p' has already returned true." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1702 (let ((oddp nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1703 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1704 (while (eq (char-before) ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1705 (setq oddp (not oddp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1706 (backward-char))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1707 oddp)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1708 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1709 (defun paredit-in-char-p (&optional arg) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1710 "True if the point is immediately after a character literal. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1711 A preceding escape character, not preceded by another escape character, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1712 is considered a character literal prefix. (This works for elisp, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1713 Common Lisp, and Scheme.) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1714 Assumes that `paredit-in-string-p' is false, so that it need not handle |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1715 long sequences of preceding backslashes in string escapes. (This |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1716 assumes some other leading character token -- ? in elisp, # in Scheme |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1717 and Common Lisp.)" |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1718 (let ((arg (or arg (point)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1719 (and (eq (char-before arg) ?\\ ) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1720 (not (eq (char-before (1- arg)) ?\\ ))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1721 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1722 (defun paredit-forward-and-indent () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1723 "Move forward an S-expression, indenting it fully. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1724 Indent with `lisp-indent-line' and then `indent-sexp'." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1725 (forward-sexp) ; Go forward, and then find the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1726 (save-excursion ; beginning of this next |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1727 (backward-sexp) ; S-expression. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1728 (lisp-indent-line) ; Indent its opening line, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1729 (indent-sexp))) ; the rest of it. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1730 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1731 (defun paredit-skip-whitespace (trailing-p &optional limit) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1732 "Skip past any whitespace, or until the point LIMIT is reached. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1733 If TRAILING-P is nil, skip leading whitespace; otherwise, skip trailing |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1734 whitespace." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1735 (funcall (if trailing-p 'skip-chars-forward 'skip-chars-backward) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1736 " \t\n" ; This should skip using the syntax table, but LF |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1737 limit)) ; is a comment end, not newline, in Lisp mode. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1738 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1739 (defalias 'paredit-region-active-p |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1740 (xcond ((paredit-xemacs-p) 'region-active-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1741 ((paredit-gnu-emacs-p) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1742 (lambda () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1743 (and mark-active transient-mark-mode))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1744 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1745 (defun kill-region-new (start end) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1746 "Kill the region between START and END. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1747 Do not append to any current kill, and |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1748 do not let the next kill append to this one." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1749 (interactive "r") ;Eh, why not? |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1750 ;; KILL-REGION sets THIS-COMMAND to tell the next kill that the last |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1751 ;; command was a kill. It also checks LAST-COMMAND to see whether it |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1752 ;; should append. If we bind these locally, any modifications to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1753 ;; THIS-COMMAND will be masked, and it will not see LAST-COMMAND to |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1754 ;; indicate that it should append. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1755 (let ((this-command nil) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1756 (last-command nil)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1757 (kill-region start end))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1758 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1759 ;;;;; S-expression Parsing Utilities |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1760 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1761 ;++ These routines redundantly traverse S-expressions a great deal. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1762 ;++ If performance issues arise, this whole section will probably have |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1763 ;++ to be refactored to preserve the state longer, like paredit.scm |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1764 ;++ does, rather than to traverse the definition N times for every key |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1765 ;++ stroke as it presently does. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1766 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1767 (defun paredit-current-parse-state () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1768 "Return parse state of point from beginning of defun." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1769 (let ((point (point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1770 (beginning-of-defun) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1771 ;; Calling PARSE-PARTIAL-SEXP will advance the point to its second |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1772 ;; argument (unless parsing stops due to an error, but we assume it |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1773 ;; won't in paredit-mode). |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1774 (parse-partial-sexp (point) point))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1775 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1776 (defun paredit-in-string-p (&optional state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1777 "True if the parse state is within a double-quote-delimited string. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1778 If no parse state is supplied, compute one from the beginning of the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1779 defun to the point." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1780 ;; 3. non-nil if inside a string (the terminator character, really) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1781 (and (nth 3 (or state (paredit-current-parse-state))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1782 t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1783 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1784 (defun paredit-string-start+end-points (&optional state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1785 "Return a cons of the points of open and close quotes of the string. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1786 The string is determined from the parse state STATE, or the parse state |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1787 from the beginning of the defun to the point. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1788 This assumes that `paredit-in-string-p' has already returned true, i.e. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1789 that the point is already within a string." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1790 (save-excursion |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1791 ;; 8. character address of start of comment or string; nil if not |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1792 ;; in one |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1793 (let ((start (nth 8 (or state (paredit-current-parse-state))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1794 (goto-char start) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1795 (forward-sexp 1) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1796 (cons start (1- (point)))))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1797 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1798 (defun paredit-in-comment-p (&optional state) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1799 "True if parse state STATE is within a comment. |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1800 If no parse state is supplied, compute one from the beginning of the |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1801 defun to the point." |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1802 ;; 4. nil if outside a comment, t if inside a non-nestable comment, |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1803 ;; else an integer (the current comment nesting) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1804 (and (nth 4 (or state (paredit-current-parse-state))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1805 t)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1806 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1807 (defun paredit-point-at-sexp-boundary (n) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1808 (cond ((< n 0) (paredit-point-at-sexp-start)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1809 ((= n 0) (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1810 ((> n 0) (paredit-point-at-sexp-end)))) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1811 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1812 (defun paredit-point-at-sexp-start () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1813 (forward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1814 (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1815 (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1816 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1817 (defun paredit-point-at-sexp-end () |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1818 (backward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1819 (forward-sexp) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1820 (point)) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1821 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1822 ;;;; Initialization |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1823 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1824 (paredit-define-keys) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1825 (paredit-annotate-mode-with-examples) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1826 (paredit-annotate-functions-with-examples) |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1827 |
9541f7e47514
Some edits to .emacs after my playing with Clojure, also added Clojure support files.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
1828 (provide 'paredit) |