2011年12月31日土曜日

ブログ作成をちょっと便利に(very personal)

<body> - </body>間をコピー

僕はブログの原稿を Emacs の org-mode で書いています。
それを html ファイルに変換して、その html ファイルから必要な部分をコピーしてブログに貼り付けています。

以下は html ファイル中の必要な部分をキーボードショートカットでコピーする個人的な改善。
前述の 'paste-to-osx' を利用して <body> と </body> の間をコピーします。(参考:ターミナル Emacs - GUIアプリ間のコピペ
;; バッファ内の2つの文字列間をクリップボードにコピー
(defun paste-to-osx-between(start-str end-str)
   (interactive "scopy between first:\nsand second:")
   (save-excursion
              (goto-char (point-min))   
              (let (copystart)
                 (if (search-forward start-str nil t)
                             (setq copystart (point))
                         (error "Cannot copy. Start string \"%s\" not found" start-str))
                 (goto-char (point-max))
                 (if (search-backward end-str nil t)
                             (backward-char)
                         (error "Cannot copy. End string \"%s\" not found" end-str))
                 (paste-to-osx(buffer-substring copystart (point))))
              (message "copy done.")))

(defun copy-between-body()
   (interactive)
   (paste-to-osx-between "<body>" "</body>"))
(define-key global-map "\C-cc" 'copy-between-body)
C-c c で <body> と </body> の間のテキストをクリップボードにコピーします。
M-x paste-to-osx-between で任意の2つの文字列を指定も可能です。他の用途があればどうぞ。


参考:やさしいEmacs‐Lisp講座








0 件のコメント:

コメントを投稿