unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Add a handler
@ 2014-04-23  1:47 Germán Arias
  2014-04-23  6:07 ` Tassilo Horn
  2014-04-23  6:34 ` Michael Albinus
  0 siblings, 2 replies; 4+ messages in thread
From: Germán Arias @ 2014-04-23  1:47 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

How add a handler at "file-name-handler-alist"?

Thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Add a handler
  2014-04-23  1:47 Add a handler Germán Arias
@ 2014-04-23  6:07 ` Tassilo Horn
  2014-04-23  6:34 ` Michael Albinus
  1 sibling, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2014-04-23  6:07 UTC (permalink / raw)
  To: Germán Arias; +Cc: help-gnu-emacs

Germán Arias <germanandre@gmx.es> writes:

Hi Germán,

> How add a handler at "file-name-handler-alist"?

Something like

  (add-to-list file-name-handler-alist
               (cons "\\.foobar\\'" #'my-foobar-handler))

should do the trick.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Add a handler
  2014-04-23  1:47 Add a handler Germán Arias
  2014-04-23  6:07 ` Tassilo Horn
@ 2014-04-23  6:34 ` Michael Albinus
  2014-04-24  7:33   ` Germán Arias
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2014-04-23  6:34 UTC (permalink / raw)
  To: Germán Arias; +Cc: help-gnu-emacs

Germán Arias <germanandre@gmx.es> 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 nil)

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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Add a handler
  2014-04-23  6:34 ` Michael Albinus
@ 2014-04-24  7:33   ` Germán Arias
  0 siblings, 0 replies; 4+ messages in thread
From: Germán Arias @ 2014-04-24  7:33 UTC (permalink / raw)
  To: help-gnu-emacs

On 2014-04-23 00:34:50 -0600 Michael Albinus <michael.albinus@gmx.de> wrote:

> Germán Arias <germanandre@gmx.es> 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 nil)
> 
> 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.
> 

Thanks, now I can add my handler, but don't seems to work. As you suggest I will see the existing handlers to take ideas.

Regards.
Germán.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-24  7:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-23  1:47 Add a handler Germán Arias
2014-04-23  6:07 ` Tassilo Horn
2014-04-23  6:34 ` Michael Albinus
2014-04-24  7:33   ` Germán Arias

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).