From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/41008 Path: main.gmane.org!not-for-mail From: Josh Huber Newsgroups: gmane.emacs.gnus.general Subject: more file coding info (for XEmacs users) Date: Thu, 27 Dec 2001 15:59:48 -0500 Organization: Mind your own business, you silly arthur king! Sender: owner-ding@hpc.uh.edu Message-ID: <87bsgktm4b.fsf@paradoxical.net> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035176475 3946 80.91.224.250 (21 Oct 2002 05:01:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 05:01:15 +0000 (UTC) Return-Path: Original-Received: (qmail 18054 invoked from network); 27 Dec 2001 21:00:29 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 27 Dec 2001 21:00:29 -0000 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 16JhdD-00070Y-00; Thu, 27 Dec 2001 15:00:03 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Thu, 27 Dec 2001 14:59:53 -0600 (CST) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id OAA18343 for ; Thu, 27 Dec 2001 14:59:40 -0600 (CST) Original-Received: (qmail 18033 invoked by alias); 27 Dec 2001 20:59:44 -0000 Original-Received: (qmail 18028 invoked from network); 27 Dec 2001 20:59:44 -0000 Original-Received: from quimby.gnus.org (HELO quimby2.netfonds.no) (195.204.10.66) by gnus.org with SMTP; 27 Dec 2001 20:59:44 -0000 Original-Received: from news by quimby2.netfonds.no with local (Exim 3.12 #1 (Debian)) id 16Jhqs-0007cy-00 for ; Thu, 27 Dec 2001 22:14:10 +0100 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 52 Original-NNTP-Posting-Host: lowell.missioncriticallinux.com Original-X-Trace: quimby2.netfonds.no 1009487650 28782 208.51.139.16 (27 Dec 2001 21:14:10 GMT) Original-X-Complaints-To: usenet@quimby2.netfonds.no Original-NNTP-Posting-Date: 27 Dec 2001 21:14:10 GMT X-Go-Away: or I shall taunt you a second time! X-PGP-KeyID: 6B21489A X-Fingerprint: 61F0 6138 BE7B FEBF A223 E9D1 BFE1 2065 6B21 489A X-Request-PGP: finger:huber@db.debian.org Mail-Copies-To: nobody User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Civil Service, powerpc-debian-linux) Cancel-Lock: sha1:J02WK/C4CdA/N1iTmJ8tgmyGbis= Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:41008 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:41008 It seems as though coding tags inside Local Variables are not supported, which is unfortunate...especially in the case of files like ChangeLog which really need this information at the end of the file. So, here's my workaround: (defun jmh:find-coding-cookie-in-local-variables (filename visit) (with-temp-buffer (let* ((attrs (file-attributes filename)) (size (nth 7 attrs)) (start (- size 3001)) (end (1- size))) (when (< start 0) (setq start 0)) (when (< end 0) (setq end 0)) ;; check only the last 3000 bytes of the file for the cookie (insert-file-contents-literally filename nil start end) (save-excursion (let (start end prefix postfix) (and (re-search-forward ;; \ between Local and Variables to make sure ;; XEmacs doesn't think it's an actual ;; Local Vars block "^\\(.*?\\)[ \t]*Local\ Variables:\\(.*\\)" nil t) (setq prefix (regexp-quote (buffer-substring (match-beginning 1) (match-end 1)))) (setq postfix (regexp-quote (buffer-substring (match-beginning 2) (match-end 2)))) (setq start (match-end 0)) (re-search-forward (concat "\n" prefix "[ \t]*End:" postfix)) (setq end (match-beginning 0)) ;; narrow to the correct region and look for the cookie (save-restriction (narrow-to-region start end) (goto-char start) (re-search-forward (concat "\n" prefix "[ \t]*coding: \\([^\n]+\\)" postfix) nil t)) (let ((codesys (intern (buffer-substring (match-beginning 1) (match-end 1))))) (if (find-coding-system codesys) codesys)))))))) (add-hook 'insert-file-contents-pre-hook 'jmh:find-coding-cookie-in-local-variables) ttyl, -- Josh Huber