path: root/debian-el.el
diff options
authorpsg <>2009-02-23 18:55:30 +0000
committerpsg <>2009-02-23 18:55:30 +0000
commitbda5d9e984bbb3dfdb68ae48bf133a80d3d2e532 (patch)
treeaed6aeaa65b162c7e018eba03ab686e1c213749a /debian-el.el
parentb3af3b67d47237b01dc3d5aa33521daa79429687 (diff)
debian-el.el: Add code from Kevin Ryde to set deb-view control file coding
system (Closes: #484027)
Diffstat (limited to 'debian-el.el')
1 files changed, 33 insertions, 1 deletions
diff --git a/debian-el.el b/debian-el.el
index 81ad523..f791a1d 100644
--- a/debian-el.el
+++ b/debian-el.el
@@ -1,4 +1,4 @@
-;;; debian-el.el --- startup file for the debian-el package
+`;;; debian-el.el --- startup file for the debian-el package
;;; Commentary:
@@ -66,6 +66,38 @@
(function (lambda ()
(define-key dired-mode-map "\C-d" 'deb-view-dired-view))))
+(when (member 'utf-8 (coding-system-list))
+ ;; The following from Kevin Ryde <>
+ ;; Closes: #484027
+ (defun deb-view-control-coding (arg-list)
+ "Return coding system for the \"control\" file in a deb.
+This function is for use from `file-coding-system-alist'.
+ARG-LIST is arguments passed to `find-operation-coding-system'.
+The only operation handled here is `insert-file-contents' with a
+buffer filename \".deb-INFO!./control\", for which the return is
+'utf-8, and for anything else the return is nil (letting
+`find-operation-coding-system' try other things).
+This is done as a function because the filename passed to
+find-operation-coding-system by tar-mode is merely the archive
+member \"./control\". By looking at the buffer-file-name we can
+tell if it's from a deb.
+Note: This only works in emacs22, in emacs21 or xemacs21 tar-mode
+does something a bit different and doesn't reach here (and
+there's no buffer passed to coding system functions)."
+ (and (eq (car arg-list) 'insert-file-contents) ;; first arg
+ (consp (cadr arg-list)) ;; second arg like ("./control" . BUFFER)
+ (let ((buffer (cdr (cadr arg-list))))
+ (and (string-match "\\.deb-INFO!\\./control\\'"
+ (buffer-file-name buffer))
+ 'utf-8))))
+ (add-to-list 'file-coding-system-alist
+ '("control" . deb-view-control-coding)))
(provide 'debian-el)
;;; debian-el.el ends here