From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.help Subject: Re: Add a handler Date: Wed, 23 Apr 2014 08:34:50 +0200 Message-ID: <87wqegeeph.fsf@gmx.de> References: <1366ad6f7a4a9624d8f90472f284f695@german-desktop> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1398234925 20422 80.91.229.3 (23 Apr 2014 06:35:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 23 Apr 2014 06:35:25 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: =?utf-8?Q?Germ=C3=A1n?= Arias Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 23 08:35:19 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wcqm6-0008N5-Dm for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Apr 2014 08:35:18 +0200 Original-Received: from localhost ([::1]:58843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcqm6-0006uw-1y for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Apr 2014 02:35:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcqlq-0006rP-05 for help-gnu-emacs@gnu.org; Wed, 23 Apr 2014 02:35:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wcqlj-0002eJ-Nb for help-gnu-emacs@gnu.org; Wed, 23 Apr 2014 02:35:01 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:49416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wcqlj-0002eB-E1 for help-gnu-emacs@gnu.org; Wed, 23 Apr 2014 02:34:55 -0400 Original-Received: from detlef.gmx.de ([93.202.61.140]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MMT1y-1WYy5T3d6c-008I6b; Wed, 23 Apr 2014 08:34:54 +0200 In-Reply-To: <1366ad6f7a4a9624d8f90472f284f695@german-desktop> (=?utf-8?Q?=22Germ=C3=A1n?= Arias"'s message of "Tue, 22 Apr 2014 19:47:27 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Provags-ID: V03:K0:lrYIDXB7jPsCVX2O/K7xkiOTdx+E4zMHm0BktxxkG/VlrZK/y/9 rntd4bFYA/stlUcARVlVvRKs9mpMxoeXp2jhzKZYIN3vNYliPWxyskEC/Jr+dsYdBlDfqx1 77lfp0tRTKQ5pqgLYSlgw6y3qKOcBO3RfGuVIBCBZ4bH+Gexe6UVh0FxxZk4wY3EpqP8938 g04c6eSqYiwVjM9SzPYRg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.15.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97321 Archived-At: Germ=C3=A1n Arias writes: > Hi, Hi, > How add a handler at "file-name-handler-alist"? First, you shall know which file names the handler is supposed to handle. You need a regexp for this, let's say "handled\\'". This would match all files which names have "handled" at their end (it's a stupid example, just for illustration). Second, you need to write a function (the "handler"), which does the work. It must have a general argument list, which would cover all supported operations. Something like this: (defun my-file-name-handler (operation &rest args) "Invoke my file name handler." (message "my-file-name-handler %s %s" operation args)) Third, you must add both to `file-name-handler-alist as cons cell: (add-to-list 'file-name-handler-alist (cons "handled\\'" 'my-file-name-handler)) If a magic file name operation is called now with a file name matching your regexp, your file name handler is called: (file-exists-p "/path/to/this-file-name-is-handled") would write into the *Messages* buffer my-file-name-handler expand-file-name (/path/to/this-file-name-is-handled n= il) That's all. Now you need only to implement all supported operations, see (info "(elisp)Magic File Names") You could also check `file-name-handler-alist' for existing file name handlers, and steal^W be inspired by their implementation. > Thanks. Best regards, Michael.