From: rubikitch Date: 2000-09-08T15:54:00+09:00 Subject: [ruby-list:24892] rd-mode.el るびきちです。 rd-mode.el のパッチです。 ({C-c i r})) や (({C-c C-u})) で Reference を入力するとき、 そのままでは使えない文字(“|”と“/”)があった場合に自動的にVerbをかぶせるものです。 Ex. (({C-c C-u http://www.debian.org \n Debian GNU/Linux})) => ((<(('Debian GNU/Linux'))|URL:http://www.debian.org>)) (({C-c C-u http://www.linux.org Linux})) => (()) --- rd-mode.el 2000/09/07 05:29:07 1.1 +++ rd-mode.el 2000/09/08 04:50:25 1.2 @@ -104,15 +104,23 @@ (define-key rd-mode-map "\C-c\C-y" 'rd-yank-pop-as-url) (define-key rd-mode-map "\C-c\C-u" 'rd-insert-url)) -(defun rd-insert-inline (beg end str) +(defun rd-refquote (str) + (if (null str) + nil + (if (string-match "[|/]" str) + (concat "(('" str "'))") + str))) + +(defun rd-insert-inline (beg end str &optional no-insert) "Insert Inline Inline (general)." (if str - (insert (concat beg str end)) - (progn - (if rd-use-prompt-when-insertion-p - (rd-insert-inline beg end (read-string (concat beg " elm " end ": "))) - (insert beg end) - (backward-char (length end)))))) + (let ((insstr (concat beg str end))) + (if no-insert insstr (insert insstr))) + (progn + (if rd-use-prompt-when-insertion-p + (rd-insert-inline beg end (read-string (concat beg " elm " end ": ")) no-insert) + (insert beg end) + (backward-char (length end)))))) (defun rd-insert-emphasis (&optional str) "Insert Inline Emphasis." @@ -136,7 +144,12 @@ (defun rd-insert-ref (&optional str) "Insert Inline Reference." - (interactive "*") (rd-insert-inline "((<" ">))" str)) + (interactive "*") (insert (rd-refquote (rd-insert-inline "((<" ">))" str t)))) + +(defun rd-insert-ref-noquote (&optional str) + "Insert Inline Reference." + (rd-insert-inline "((<" ">))" str)) + (defun rd-insert-reftourl (&optional str) "Insert Inline RefToURL." @@ -252,7 +265,7 @@ (interactive "sURL: \nsLabel: ") (if (string= label "") (rd-insert-reftourl url) - (rd-insert-ref (concat label "|URL:" url)))) + (rd-insert-ref-noquote (concat (rd-refquote label) "|URL:" url)))) (defun rd-search-labels () "Search Label of RD for abbrev." るびきち☆ http://i.am/rubikitch