Function: ffap-gopher-at-point

ffap-gopher-at-point is a byte-compiled function defined in ffap.el.gz.

Signature

(ffap-gopher-at-point)

Documentation

If point is inside a gopher bookmark block, return its URL.

Sets the variable ffap-string-at-point-region to the bounds of URL, if any.

Source Code

;; Defined in /usr/src/emacs/lisp/ffap.el.gz
(defun ffap-gopher-at-point ()
  "If point is inside a gopher bookmark block, return its URL.

Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
  ;; `gopher-parse-bookmark' from gopher.el is not so robust
  (when (stringp ffap-gopher-regexp)
    (save-excursion
      (let* ((beg (progn (beginning-of-line)
                         (while (and (not (bobp)) (ffap--gopher-var-on-line))
                           (forward-line -1))
                         (point)))
             (bookmark (cl-loop for keyval = (ffap--gopher-var-on-line)
                                while keyval collect keyval
                                do (forward-line 1)
                                until (eobp))))
        (when bookmark
          (setq ffap-string-at-point-region (list beg (point)))
          (let-alist (nconc bookmark '((type . "1") (port . "70")))
            (if (and .path (string-match "\\`ftp:.*@" .path))
                (concat "ftp://"
                        (substring .path 4 (1- (match-end 0)))
                        (substring .path (match-end 0)))
              (and (= (length .type) 1)
                   .host ;; (ffap-machine-p host)
                   (concat "gopher://" .host
                           (if (equal .port "70") "" (concat ":" .port))
                           "/" .type .path)))))))))