forked from beagleboard/image-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortregion.el
59 lines (44 loc) · 1.49 KB
/
sortregion.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
;; goal: sanitize package lists so they can be reasobably diff'ed
;; approach: define an emacs function which transforms this:
;; fasel="apt-transport-https alsa-utils apache2 autoconf automake avahi-daemon bash-completion \
;; u-boot-tools usb-modeswitch usbutils v4l-utils vim wget wireless-tools \
;; wpasupplicant wvdial zd1211-firmware"
;; into this (in-place):
;; fasel=" \
;; alsa-utils \
;; apache2 \
;; apt-transport-https \
;; autoconf \
;; automake \
;; avahi-daemon \
;; bash-completion \
;; u-boot-tools \
;; usb-modeswitch \
;; usbutils \
;; v4l-utils \
;; vim \
;; wget \
;; wireless-tools \
;; wpasupplicant \
;; wvdial \
;; zd1211-firmware \
;; "
;; usage: mark region including double quotes, then execute M-/
;; file this into a Python script:
;; #!/usr/bin/python
;; import sys
;; data=sorted(sys.stdin.read().replace('\n', '').replace('\\', '').replace('"', '').split())
;; tabbed = ['\t' + name for name in data]
;; print '"\t\\\n'+ '\t\\\n'.join(tabbed) + '\t\\\n"'
;; fix scriptName below
;; add to .emacs
;; lifted from: http://ergoemacs.org/emacs/elisp_perl_wrapper.html
(defun do-something-region (startPos endPos)
"Do some text processing on region.
This command calls the external script “wc”."
(interactive "r")
(let (scriptName)
(setq scriptName "/home/mah/omap-image-builder/emacs/fixpkglists.py") ; full path to your script
(shell-command-on-region startPos endPos scriptName nil t nil t)
))
(global-set-key (kbd "M-/") 'do-something-region )