From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?iso-8859-1?q?Germ=E1n_Arias?= Newsgroups: gmane.emacs.help Subject: Re: Add a handler Date: Thu, 24 Apr 2014 01:33:12 -0600 Message-ID: References: <87wqegeeph.fsf@gmx.de> Reply-To: germanandre@gmx.es NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Generated by Pantomime 1.2.0) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1398324922 1249 80.91.229.3 (24 Apr 2014 07:35:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Apr 2014 07:35:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 24 09:35:15 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 1WdEBf-0005N6-6g for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Apr 2014 09:35:15 +0200 Original-Received: from localhost ([::1]:36502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdEBe-0002bK-Pa for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Apr 2014 03:35:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdE9o-0001uk-GH for help-gnu-emacs@gnu.org; Thu, 24 Apr 2014 03:33:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdE9j-0000Vm-3e for help-gnu-emacs@gnu.org; Thu, 24 Apr 2014 03:33:20 -0400 Original-Received: from mout.gmx.net ([74.208.4.200]:49952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdE9i-0000Vb-Us for help-gnu-emacs@gnu.org; Thu, 24 Apr 2014 03:33:15 -0400 Original-Received: from localhost.localdomain ([190.149.95.155]) by mail.gmx.com (mrgmxus001) with ESMTPSA (Nemesis) id 0MdrNz-1WGRZV2UrV-00PcD3 for ; Thu, 24 Apr 2014 09:33:12 +0200 In-Reply-To: <87wqegeeph.fsf@gmx.de> User-Agent: GNUMail (Version 1.2.1) X-Provags-ID: V03:K0:n6TaIfkDSdQAxI/nWAajDB7ZvO7KpcTfq7006e7ncztBTDXKFi1 TIT8I9EZmXqyYyA3y0+HlTWWynV0anmg9SVfluYczSLkU+017zwG9sDSD6o1U1/Ddg6qulu JBLPOxd6HCoB8b7Z3QsEuuGQyDRpkpFPzlmGgmSYIMyN9f6gJkLci/pDTpGjH7jKrHhjVET 0IMQcK+LFJVIC8RcSk+7Q== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 74.208.4.200 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:97354 Archived-At: On 2014-04-23 00:34:50 -0600 Michael Albinus wr= ote: > Germ=E1n Arias writes: >=20 >> Hi, >=20 > Hi, >=20 >> How add a handler at "file-name-handler-alist"? >=20 > 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). >=20 > 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: >=20 > (defun my-file-name-handler (operation &rest args) > "Invoke my file name handler." > (message "my-file-name-handler %s %s" operation args)) >=20 > Third, you must add both to `file-name-handler-alist as cons cell: >=20 > (add-to-list 'file-name-handler-alist > (cons "handled\\'" 'my-file-name-handler)) >=20 > If a magic file name operation is called now with a file name matching= > your regexp, your file name handler is called: >=20 > (file-exists-p "/path/to/this-file-name-is-handled") >=20 > would write into the *Messages* buffer >=20 > my-file-name-handler expand-file-name (/path/to/this-file-name-is-hand= led nil) >=20 > That's all. Now you need only to implement all supported operations, s= ee > (info "(elisp)Magic File Names") >=20 > You could also check `file-name-handler-alist' for existing file name > handlers, and steal^W be inspired by their implementation. >=20 >> Thanks. >=20 > Best regards, Michael. >=20 Thanks, now I can add my handler, but don't seems to work. As you sugges= t I will see the existing handlers to take ideas. Regards. Germ=E1n.