Variable: browse-url-filename-alist

browse-url-filename-alist is a customizable variable defined in browse-url.el.gz.

Value

(("^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*" . "ftp://\\2/")
 ("^/\\([^:@/]+@\\)?\\([^:/]+\\):/*" . "ftp://\\1\\2/")
 ("^/+" . "file:///"))

Documentation

An alist of (REGEXP . STRING) pairs used by browse-url-of-file.

Any substring of a filename matching one of the REGEXPs is replaced by the corresponding STRING using replace-match, not treating STRING literally. All pairs are applied in the order given. The default value converts ange-ftp-style file names into ftp URLs and prepends file: to any file name beginning with /.

For example, adding to the default a specific translation of an ange-ftp address to an HTTP URL:

    (setq browse-url-filename-alist
'(("/webmaster@webserver:/home/www/html/" .
             "https://www.example.org/")
            ("^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*" . "ftp://\\2/")
            ("^/\\([^:@/]+@\\)?\\([^:/]+\\):/*" . "ftp://\\1\\2/")
("^/+" . "file:/")))

This variable was added, or its default value changed, in Emacs 25.1.

Source Code

;; Defined in /usr/src/emacs/lisp/net/browse-url.el.gz
(defcustom browse-url-filename-alist
  `(("^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*" . "ftp://\\2/")
    ;; The above loses the username to avoid the browser prompting for
    ;; it in anonymous cases.  If it's not anonymous the next regexp
    ;; applies.
    ("^/\\([^:@/]+@\\)?\\([^:/]+\\):/*" . "ftp://\\1\\2/")
    ,@(if (memq system-type '(windows-nt ms-dos))
          '(("^\\([a-zA-Z]:\\)[\\/]" . "file:///\\1/")
            ("^[\\/][\\/]+" . "file://")))
    ("^/+" . "file:///"))
  "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
Any substring of a filename matching one of the REGEXPs is replaced by
the corresponding STRING using `replace-match', not treating STRING
literally.  All pairs are applied in the order given.  The default
value converts ange-ftp-style file names into ftp URLs and prepends
`file:' to any file name beginning with `/'.

For example, adding to the default a specific translation of an ange-ftp
address to an HTTP URL:

    (setq browse-url-filename-alist
	  \\='((\"/webmaster@webserver:/home/www/html/\" .
             \"https://www.example.org/\")
            (\"^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*\" . \"ftp://\\2/\")
            (\"^/\\([^:@/]+@\\)?\\([^:/]+\\):/*\" . \"ftp://\\1\\2/\")
	    (\"^/+\" . \"file:/\")))"
  :type '(repeat (cons :format "%v"
                       (regexp :tag "Regexp")
                       (string :tag "Replacement")))
  :version "25.1")