emacs のテキスト中の URL をひらく

browse-url-at-point を ttp:/... (h 抜き) に対応させる。thingatpt.el から該当部分を取って来て、改変して .emacs に書く。

thing-at-point-url-regexp を変える。

(setq thing-at-point-url-regexp
      (concat
       "\\<\\(ttps?://\\|h?ttps?://\\|ftp://\\|gopher://\\|telnet://\\|wais://\\|file:/\\|s?news:\\|mailto:\\)"
       thing-at-point-url-path-regexp))

これだけではまだだめ。さらに thing-at-point-url-at-point も変える。

(defun thing-at-point-url-at-point ()
  (let ((url "") short strip)
    (if (or (setq strip (thing-at-point-looking-at
                         thing-at-point-markedup-url-regexp))
            (thing-at-point-looking-at thing-at-point-url-regexp)
            ;; Access scheme omitted?
            (setq short (thing-at-point-looking-at
                         thing-at-point-short-url-regexp)))
        (progn
          (setq url (buffer-substring-no-properties (match-beginning 0)
                                                    (match-end 0)))
          (and strip (setq url (substring url 5 -1))) ; Drop "<URL:" & ">"
          ;; strip whitespace
          (while (string-match "[ \t\n\r]+" url)
            (setq url (replace-match "" t t url)))
          (and short (setq url (concat (cond ((string-match "@" url)
                                              "mailto:")
                                             ;; e.g. ftp.swiss... or ftp-swiss...
                                             ((string-match "^ftp" url)
                                              "ftp://")
                                             (t "http://"))
                                       url)))
	  (if (string-match "^ttps?://" url)  ;;; <--ここ---
	      (setq url (concat "h" url)))    ;;; <--ここ---
	  (if (string-equal "" url)
              nil
            url)))))