From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Florian von Savigny Newsgroups: gmane.emacs.help Subject: Re: make-auto-save-file-name: not using name transforms for mere buffers Date: 11 Dec 2003 12:46:02 +0100 Organization: 1&1 Internet AG Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1071144417 5133 80.91.224.253 (11 Dec 2003 12:06:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2003 12:06:57 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 11 13:06:54 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AUPao-000239-00 for ; Thu, 11 Dec 2003 13:06:54 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AUQVF-0000ii-EF for geh-help-gnu-emacs@m.gmane.org; Thu, 11 Dec 2003 08:05:13 -0500 Original-Newsgroups: gnu.emacs.help Original-Lines: 122 Original-NNTP-Posting-Host: pd9506f4a.dip0.t-ipconnect.de Original-X-Trace: online.de 1071143167 9747 217.80.111.74 (11 Dec 2003 11:46:07 GMT) Original-X-Complaints-To: abuse@einsundeins.com Original-NNTP-Posting-Date: Thu, 11 Dec 2003 11:46:07 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news-FFM2.ecrc.net!news.netplace.de!feed.news.tiscali.de!news.belwue.de!news.uni-ulm.de!rz.uni-karlsruhe.de!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail Original-Xref: shelby.stanford.edu gnu.emacs.help:119213 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:15152 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:15152 "Eli Zaretskii" writes: > Because its doc string says, in its very first line: > > *Transforms to apply to buffer file name before making auto-save file name. > ^^^^^^^^^^^^^^^^^^^ > So buffers with no file name are not subject to such transforms. Ok, so it doesn't do it because it is not told so ;-) but I still wonder why it is told not to do so (I mean why, in the first place, the author decided not to apply this feature to file names derived from mere buffer names). > Instead of hacking make-auto-save-file-name, I'd suggest to hack > convert-standard-file-name. On GNU and Unix systems, this function > simply returns its argument. What you need is to redefine it so that > it recognizes that its argument file resides on a VFAT volume, and > then applies the same transformations done by the MS-Windows variant > of convert-standard-file-name (see w32-fns.el). Wow, thanks for this hint; it does sound like a sane approach. But I still need to understand when, in the particular case of auto-save file names derived from buffer names, convert-standard-file-name takes effect. AFAICS, it is not called directly from within make-auto-save-file-name. I couldn't make out where, or if, it is called indirectly. However, I've made a start. I've decided that no direct function to the kernel to query mounted filesystems seems available, and between looking at the output of /proc/mounts and calling mount with no arguments, I've decided to do the latter (I don't know if any approach is favourable over the other). I thought it would be more feasible to cache this information: (setq file-systems nil) ; alist of ((MOUNTPOINT . FS-TYPE) ... etc. (defun cache-file-systems () "Function to set `file-systems' automatically." (interactive) ; useful after mounts, could also be called by gnuclient (call-process "mount" nil "*mount*" nil) (save-excursion (set-buffer "*mount*") (goto-char (point-min)) (while (search-forward-regexp " on \\([^ ]+\\) type \\([^ ]+\\)" nil t) (setq file-systems (cons (cons (match-string 1) (match-string 2)) file-systems))) (kill-buffer "*mount*"))) So far, this works. Now we need to query it: (defun filename-get-fs (filename) "Returns, as a string, the type of file system within the realm of which a filename falls. Depends on the correct setting of `file-systems', which can be guaranteed by setting it with `cache-file-systems'." ;; for this to be really sane, file-systems must be sorted such that ;; those pairs with the longest mount points come first (setq filename (expand-file-name filename)) (let ((ind 0) mount-point) (catch 'result (while (setq mount-point (car (nth ind file-systems))) (if (< (length mount-point) (length filename)) (if (string-equal mount-point (substring filename 0 (length mount-point))) (throw 'result (cdr (nth ind file-systems))))) (setq ind (+ ind 1)))))) But here I'm stuck. For the function to be sane, the list must be sorted longest mountpoint first (notably, "/" must be the last entry, because it matches everything). How to do this? This function working, it could be used inside convert-standard-file-name like: (cond ((equal (filename-get-fs filename) "vfat") (;; apply certain transforms)) (( ... (haven't checked the syntax, but you get the idea) For looking up transforms, I'd like to have a list of alists of a value and a list of alists each ;-) ... is that possible? This one here doesn't work: (defvar file-name-char-transforms '(("vfat" . (("*" . "_") (":" . "%") ("ä" . "ae") ("ö" . "oe") ("ü" . "ue") ("ß" "ss"))) ("fat" . (("*" . "_") (":" "%")))) "Complexly structured list containing rules how to translate filename characters in the context of given file systems.") -- Florian v. Savigny If you are going to reply in private, please be patient, as I only check for mail something like once a week. - Si vous allez répondre personellement, patientez s.v.p., car je ne lis les courriels qu'environ une fois par semaine. -- Florian v. Savigny If you are going to reply in private, please be patient, as I only check for mail something like once a week. - Si vous allez répondre personellement, patientez s.v.p., car je ne lis les courriels qu'environ une fois par semaine.