summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorAlan Pearce2014-08-09 10:17:48 +0100
committerAlan Pearce2014-08-09 10:17:48 +0100
commit03be1651e1dc1ce28b4f8fa3a619d7fa1f3453b3 (patch)
tree62dea78d98e023fa992fa2ac5e56664e3bbcd74f /content
parent8fcfe5b8eee07bbccbdcca633c0c5c68492bdaea (diff)
downloadwebsite-03be1651e1dc1ce28b4f8fa3a619d7fa1f3453b3.tar.xz
website-03be1651e1dc1ce28b4f8fa3a619d7fa1f3453b3.zip
New post: Cedit and Paredit
Diffstat (limited to 'content')
-rw-r--r--content/post/cedit-and-paredit.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/content/post/cedit-and-paredit.md b/content/post/cedit-and-paredit.md
new file mode 100644
index 0000000..ff6cce3
--- /dev/null
+++ b/content/post/cedit-and-paredit.md
@@ -0,0 +1,44 @@
1+++
2Categories = ["Development", "Emacs"]
3Description = "Cedit and paredit for structural editing"
4Tags = ["Development", "Emacs"]
5title = "Cedit and Paredit"
6date = 2014-08-04T07:10:14Z
7+++
8
9I recently discovered [cedit][], which provides some structural
10commands for editing c-like languages. (See this
11[Emacs Rocks! episode][e14] if you're not familiar with the concept:
12it introduces [paredit][], a structural editing mode for lisps).
13
14So, it deals with curly braces and semicolons, keeping things balanced
15and correct as show in its [screencast][cedit-readme]. It mentions that it
16integrates with [paredit][] rather than duplicating *all* its
17functionality. After setting up cedit, I decided to try enabling
18paredit alongside cedit and disabling autopair. Once I did,
19however, I noticed an annoying formatting issue: If I were to type
20`foo` and then `(`, paredit would format this as `foo ()`, which makes
21sense, considering that paredit is written for lisps — s-expressions
22are usually separated by spaces — but not so much for c-like languages.
23
24I was thinking about disabling paredit and going back to autopair,
25when I decided to look through the configuration variables for
26paredit. Turns out it provides
27`paredit-space-for-delimiter-predicates`, which is a list of functions
28that control whether a space should be inserted. So, solving the
29formatting issue turned out to be pretty simple:
30
31{{% highlight cl %}}
32(defun ap/cedit-space-delimiter-p (endp delimiter)
33"Don't insert a space before delimiters in c-style modes"
34(not cedit-mode))
35(add-to-list 'paredit-space-for-delimiter-predicates #'ap/cedit-space-delimiter-p)
36{{% /highlight %}}
37
38Hopefully that saves someone some time if they try to use the two
39together.
40
41[cedit]: https://github.com/zk-phi/cedit
42[cedit-readme]: https://github.com/zk-phi/cedit#readme
43[e14]: http://emacsrocks.com/e14.html
44[paredit]: http://www.emacswiki.org/emacs/ParEdit