Function: with-parsed-tramp-archive-file-name

with-parsed-tramp-archive-file-name is a macro defined in tramp-archive.el.gz.

Signature

(with-parsed-tramp-archive-file-name FILENAME VAR &rest BODY)

Documentation

Parse an archive filename and make components available in the BODY.

This works exactly as with-parsed-tramp-file-name for the Tramp file name structure returned by tramp-archive-dissect-file-name. A variable foo-archive (or archive) will be bound to the archive name part of FILENAME, assuming foo (or nil) is the value of VAR. OTOH, the variable foo-hop (or hop) won't be offered.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-archive.el.gz
(defmacro with-parsed-tramp-archive-file-name (filename var &rest body)
  "Parse an archive filename and make components available in the BODY.
This works exactly as `with-parsed-tramp-file-name' for the Tramp
file name structure returned by `tramp-archive-dissect-file-name'.
A variable `foo-archive' (or `archive') will be bound to the
archive name part of FILENAME, assuming `foo' (or nil) is the
value of VAR.  OTOH, the variable `foo-hop' (or `hop') won't be
offered."
  (declare (debug (form symbolp body))
           (indent 2))
  (let ((bindings
         (mapcar
	  (lambda (elem)
            `(,(if var (intern (format "%s-%s" var elem)) elem)
              (,(intern (format "tramp-file-name-%s" elem))
               ,(or var 'v))))
	  (cons
	   'archive
	   (delete
	    'hop
	    (cdr (mapcar #'car (cl-struct-slot-info 'tramp-file-name))))))))
    `(let* ((,(or var 'v) (tramp-archive-dissect-file-name ,filename))
            ,@bindings)
       ;; We don't know which of those vars will be used, so we bind them all,
       ;; and then add here a dummy use of all those variables, so we don't get
       ;; flooded by warnings about those vars `body' didn't use.
       (ignore ,@(mapcar #'car bindings))
       ,@body)))