Top / MeadowMemo / 書き散らかしメモツール―howm
最新の10件を表示しています。 コメントページを参照 はじめにhowm に関するメモや設定です。
インストールはhowmのディレクトリごとsite-lisp以下へコピー.howmの下にあるディレクトリjaを~/howm 下へコピー. (setq howm-menu-lang 'ja) (global-set-key "\C-c,," 'howm-menu) (mapc (lambda (f) (autoload f "howm-mode" "Hitori Otegaru Wiki Modoki" t)) '(howm-menu howm-list-all howm-list-recent howm-list-grep howm-create howm-keyword-to-kill-ring)) (add-hook 'howm-mode-on-hook 'auto-fill-mode) (setq howm-view-grep-parse-line "^\\(\\([a-zA-Z]:/\\)?[^:]*\\.howm\\):\\([0-9]*\\):\\(.*\\)$") (setq howm-excluded-file-regexp "/\\.#\\|[~#]$\\|\\.bak$\\|/CVS/\\|\\.doc$\\|\\.pdf$\\|\\.ppt$\\|\\.xls$") で試してます。何かいい設定があれば、追加をお願いします。そのうちに、2ちゃんねるもサルベージしてしまおう。 検索関連namazuで検索namazu.elが必要ですが,以下のようにすればnamazuで検索してその結果をhowmで表示で きます.moccur+namazuのものをそのままコピーしただけですが,動いているみたいです。 後はgnus-namazuみたいに自動的にインデックスを作ったり,アップデートしたりする汎 用的なインターフェイスが欲しいな. (require 'namazu) (defun namazu-howm-grep (&optional page-num namazu-dir key) "namazu + howm" (interactive (list 0 (if (or (and (not namazu-always-query-index-directory) current-prefix-arg) (and namazu-always-query-index-directory (not current-prefix-arg))) (completing-read "Namazu index directory: " namazu-dir-alist nil t nil 'namazu-index-history) ;;(read-from-minibuffer "Namazu index directory: " nil ;; namazu-minibuffer-map nil 'namazu-index-history) nil) (read-from-minibuffer "Enter Keyword: " nil namazu-minibuffer-field-map nil 'namazu-keyword-history))) (let* ((namazu-filename-list nil) (dir (or namazu-dir (progn (or namazu-default-dir (setq namazu-default-dir (namazu-get-default-index-dir))) (expand-file-name namazu-default-dir)))) (arg-list (list "-all" key))) (if (and dir (not (string= dir "")) (string-match "[^ \t]" dir)) (setq arg-list (append arg-list (namazu-split-dir (namazu-expand-dir-alias dir))))) (message "Namazu running ...") (let ((default-process-coding-system (cons namazu-cs-read namazu-cs-write)) (process-input-coding-system namazu-cs-read) (process-output-coding-system namazu-cs-write) (coding-system-for-read namazu-cs-read) (coding-system-for-write namazu-cs-write)) (with-temp-buffer (apply (function call-process) namazu-command nil t nil arg-list) (goto-char (point-min)) (setq namazu-filename-list (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n")))) (message "Namazu running ... done!") (setq namazu-filename-list (mapcar '(lambda (file) (if (string-match "^/\\([a-zA-Z]\\)|/\\(.+\\)$" file) (concat (match-string 1 file) ":/" (match-string 2 file)) file)) namazu-filename-list)) (if (> (length namazu-filename-list) namazu-search-num) (setq namazu-filename-list (reverse (nthcdr (- (length namazu-filename-list) namazu-search-num) (reverse namazu-filename-list))))) (let ((moccur-split-word t) (regexp key) (ti0 (current-time))) (while (string-match " " regexp nil) (setq regexp (replace-match "\\\\|" nil nil regexp))) (howm-view-search regexp namazu-filename-list) (howm-list-normalize regexp) (howm-message-time-from ti0) ))) 自動保存との関係保存前にバッファのスキャンをしているため、自動保存をしていると、遅くて使えない。オフになるようにした方がいい。 あるいはhowm側をオフにする。 via http://megadriver.ns.tc/~fumi/?date=20031005#c03 (setq howm-menu-refresh-after-save nil) ;; メニューを自動更新しない (setq howm-refresh-after-save nil) ;; 下線を引き直さない howm 以外での howm-modehowm-mode を *.howm 以外で使う時にはメニューの更新などは不要だが、*.howm の時には更新して欲しいという場合には以下のようにする。 (defadvice howm-after-save (around not-refresh-other-file activate) (let* ((howm-menu-refresh-after-save (if (and (buffer-file-name) (string-match "\\.howm" (buffer-file-name))) t nil)) (howm-refresh-after-save howm-menu-refresh-after-save)) ad-do-it)) メモの削除は?内容の無いファイルを削除 MeadowMemo:howmに追加しました。MeadowMemoにあるのは以下のものとは異なり、確認せずに消すタイプです。 diredで消せというのではなく、、、 バッファの内容を消したらファイルも消して欲しい (if (not (memq 'delete-file-if-no-contents after-save-hook)) (setq after-save-hook (cons 'delete-file-if-no-contents after-save-hook))) (defun delete-file-if-no-contents () (when (and (buffer-file-name (current-buffer)) (= (point-min) (point-max))) (when (y-or-n-p "Delete file and kill buffer?") (delete-file (buffer-file-name (current-buffer))) (kill-buffer (current-buffer))))) こんな感じ?バッファの内容が0で保存すると、y-or-nで尋ねられる。yなら、ファイルとバッファを削除する。 キャプチャの入力MeadowMemo:imcap にC-wで画像を削除する設定などがあります。 Winshot + imcap.el で可能.詳しくは howm Wikiの 画像取り込み を 参照のこと.設定済み Meadow なら何もしなくても ImageMagick? が入っていれば利用で きます. ![]() のようなことが可能.単なるリンクとして実装されており,次回に開く時には >>> 2004-01-29-074156.jpg のように表示される. (add-hook 'howm-view-open-hook 'imcap-display) としておくと,RET でメモ選択時に画像を表示できる. imcap.el アイデア書式をバッファローカルにしてしまうと面白いかも。そうすると、もっと応用が広がる。例えば、HTMLでキャプチャを入力とか。 こんな感じ。 ![]() ちなみにこれはソースをほとんど修正していない。 (add-hook 'html-mode-hook (lambda () (setq imcap-paste-format " を設定し、imcap.el を以下のように修正しただけ。 (defvar imcap-capture-command-format "import %s") (defvar imcap-paste-format ">>> %s") +(make-variable-buffer-local 'imcap-paste-format) (defvar imcap-file-name-format "%Y-%m-%d-%H%M%S.jpg") +(make-variable-buffer-local 'imcap-file-name-format) (defvar imcap-directory nil) ;; nil means current directory ; (defvar imcap-directory "~/imcap") imcap-thumb-displayお遊び. imcap-display と同じもの.ただし,サムネイルを表示する.thumbs.el と連携させることを考えた方がいいような。。。 (defun imcap-thumb-display () (interactive) (save-excursion (goto-char (point-min)) (let ((buffer-read-only nil) (modified-p (buffer-modified-p))) (while (imcap-goto-next-image) (let* ((region (imcap-image-region)) (filename (imcap-image-file)) (fileloc (imcap-expand-file-name filename))) (when (file-exists-p fileloc) (let* ((start (car region)) (end (cadr region)) (thum (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents filename) (call-process-region (point-min) (point-max) "convert" t t nil "-sample" "100x100" "-" "-") (buffer-string))) (image (create-image thum nil t)) ) (add-text-properties start end (list 'display image 'intangible image 'rear-nonsticky (list 'display))))))) (set-buffer-modified-p modified-p)))) 要望サムネイルもいいのですが、キャプチャしてメモに貼り付けたとき、やっぱり画像が大きすぎるとか小さすぎるとかあります。そこで、画像を拡大縮小が出来、それを元のキャプチャ画像と置き換えれれば、便利になりそうです。 作ってみました。 MeadowMemo:imcap resize を参照ください。 imcap何だかんだと変更して,現在設定済みMeadowに附属している imcap.el は http://howm.sourceforge.jp/cgi-bin/hiki/hiki.cgi?ImageCapture にあるのに以下のよ うな変更をしています. --- /cygdrive/d/howm/imcap.el 2004-04-26 22:33:11.847566400 +0900 +++ ./imcap.el 2004-04-26 22:38:45.897907200 +0900 @@ -18,17 +18,14 @@ (let* ((filename (format-time-string imcap-file-name-format (current-time))) (fileloc (imcap-expand-file-name filename)) (command (format imcap-capture-command-format fileloc)) - (command-name (car (split-string command))) - (arguments (cdr (split-string command))) (paste (format imcap-paste-format (if imcap-directory - (abbreviate-file-name fileloc) + fileloc filename)))) (when (and (file-exists-p fileloc) (not (y-or-n-p ("File %s exists. Overwrite? " fileloc)))) (error)) - (apply 'call-process command-name nil t nil arguments) - ;;(shell-command command) + (shell-command command) (insert paste) (imcap-display) (message fileloc))) @@ -46,7 +43,7 @@ (when (file-exists-p fileloc) (let ((start (car region)) (end (cadr region)) - (image (cons 'image (cdr (create-image fileloc nil nil :ascent 100))))) + (image (cons 'image (cdr (create-image fileloc))))) (add-text-properties start end (list 'display image 'intangible image @@ -56,8 +53,7 @@ ;;; private (defun imcap-expand-file-name (filename) - ;;(abbreviate-file-name (expand-file-name filename imcap-directory))) - (expand-file-name filename imcap-directory)) + (abbreviate-file-name (expand-file-name filename imcap-directory))) (defun imcap-goto-next-image () (let ((regexp (format (regexp-quote imcap-paste-format) Cygwin を不要にするオリジナルは shell-command で呼び出しており,Cygwin が必要となってしまう.そこで, 以下のように修正する.これで,Cygwin がなくてもいいはず. (defun imcap-capture () (interactive) (let* ((filename (format-time-string imcap-file-name-format (current-time))) (fileloc (imcap-expand-file-name filename)) (command (format imcap-capture-command-format fileloc)) (command-name (car (split-string command))) (arguments (cdr (split-string command))) (paste (format imcap-paste-format (if imcap-directory (abbreviate-file-name fileloc) filename)))) (when (and (file-exists-p fileloc) (not (y-or-n-p ("File %s exists. Overwrite? " fileloc)))) (error)) (apply 'call-process command-name nil t nil arguments) ;;(shell-command command) (insert paste) (imcap-display) (message fileloc))) action-lock の活用アウトラインとの併用
howm の action-lock は便利です.これはアンダーラインがついた文字上で RET するこ とで,その文字に関連したコマンドを実行する機能です. 例えば,以下のようにしておくと,
これだけでその章以下を隠すことができます. (autoload 'howm-mode "howm-mode" "Hitori Otegaru Wiki Modoki" t) (defadvice howm-mode (before outline-minor activate) (outline-minor-mode t)) (require 'outline) (defun my-outline-flip-subtree (&optional dummy) (interactive) (if (save-excursion (forward-line 1) (let ((p (overlays-at (line-beginning-position))) (ol nil)) (while (and p (not ol)) (setq ol (overlay-get (car p) 'invisible)) (setq p (cdr p))) ol)) (show-subtree) (hide-subtree))) (defun add-my-action-lock-rule () (let ((rule (action-lock-general 'my-outline-flip-subtree (if (and buffer-file-name (string-match "\\.howm$" buffer-file-name)) "^ *\\(\\*\\**\\)" (concat "\\(" outline-regexp "\\)")) 1 1))) (if (not (member rule action-lock-default-rules)) (progn (setq action-lock-default-rules (cons rule action-lock-default-rules)) (action-lock-set-rules action-lock-default-rules))))) (add-hook 'action-lock-mode-on-hook 'add-my-action-lock-rule) コマンドの実行適当な関数を実行したくなる時があります。そんな時には >>> f:emacs-lisp-mode とでも書いておいて RET。これで、モードの変更ができます。 以下は設定サンプル。参考にどうぞ。 (defun call-interactively2 (str) (call-interactively (read str)) (howm-mode 1) ) (setq action-lock-default-rules (cons (action-lock-general 'call-interactively2 "^>>> f:\\(.+\\)" 1 0) action-lock-default-rules)) タイトルの入力面倒だから入れない。だけど、検索のために大雑把なタイトルは入れたいというわがままな要求を見たすために、以下のような設定を使ってます。 clmemoの関数をそのまま借用しているので、clmemoが必須です。 (defvar my-howm-entry nil) (defadvice howm-create (before get-entry activate) (require 'clmemo) (setq my-howm-entry (clmemo-get-entry))) (defadvice howm-create (after input-get-entry activate) (goto-char (point-min)) (end-of-line) (insert my-howm-entry) (setq my-howm-entry nil) (goto-char (point-max))) スクラップ機能こんな機能ってあったっけと思いつつ,適当にでっち上げたもの.リージョンで範囲を選 択し,C-csとすると howm のメモを作成し,その範囲を貼り付けてくれます.2ちゃんね るを読んでいて,これいいなと思った時や w3m でコピーしたいページがあった時にhowm でさくっとメモできます(設定済みMeadowには追加済み). (defun mmemo-howm-scrap (&optional arg) (interactive "P") (let (category memo-text str (cbuf (current-buffer)) (via (cond ((string= 'w3m-mode major-mode) w3m-current-url )))) (cond (mark-active (setq str (buffer-substring (region-beginning) (region-end))) (setq category (read-from-minibuffer "input title : " "スクラップ")) (howm-create-file-with-title category nil nil nil "") (goto-char (point-max)) (save-excursion (insert str) (if via (insert (concat "\nvia " via))) )) (t (message "メモを取る範囲をリージョンで選択してください"))))) (global-set-key "\C-cs" 'mmemo-howm-scrap) ついでに,snap.elでリンクも貼り付けてもいいかもな. [2005-06-21 14:02] (setq howm-content-from-region t) じゃダメ? (shun) お遊び検索機能の活用関数を見て分かる人だけに. (defun my-howm-list-grep-fixed (dir) (interactive "DInput Directory:") (let ((howm-directory dir)) (howm-list-grep t))) |