Skip to content

Commit

Permalink
emacs helper: sanitize package lists so they can be diff'd
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Haberler committed Apr 10, 2016
1 parent 52129db commit b678c50
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
7 changes: 7 additions & 0 deletions emacs/fixpkglists.py
@@ -0,0 +1,7 @@
#!/usr/bin/python
# I do not understand the insanities of Emacs Lisp.

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"'
59 changes: 59 additions & 0 deletions emacs/sortregion.el
@@ -0,0 +1,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 )

0 comments on commit b678c50

Please sign in to comment.