(require 'howm) (defadvice howm-menu-random (around sacha activate) "Display three random items" (let ((howm-menu-recent-num 3)) ad-do-it)) (setq howm-menu-recent-num 5) (defun howm-menu-books () (howm-menu-general "books" nil (howm-tagged-menu 5 "book"))) (add-to-list 'howm-menu-display-rules '("%books" . "%here%(howm-menu-books)")) (add-to-list 'howm-menu-allow 'howm-menu-books) (defun howm-tagged-menu (num tags) ;; Bug: (length howm-recent-menu) can be smaller than NUM ;; when empty files exist. (let* ((summarizer #'(lambda (file line content) content)) ;; Unique name is needed for dynamic binding. Sigh... (h-r-m-evaluator (lambda (f) (howm-view-xtime f 'm))) (sorted (howm-sort (lambda (f) (funcall h-r-m-evaluator f)) #'howm-view-string> (mapcar #'howm-item-name (howm-folder-items `(:tag ,tags ,howm-directory) )))) (files (howm-first-n sorted num)) (items (howm-view-search-items (howm-menu-recent-regexp) files summarizer))) (howm-first-n items num))) (defun howm-folder-items:tag (specifier) "Return a file list for tagged items." (let ((tags (nth 1 specifier)) (dir (nth 2 specifier))) (howm-folder-items:files (howm-make-folder:files (tagging-grep-directory tags dir))))) (defun sacha/howm-update () "Move this entry to an updated timestamp." (interactive) (let* ((r (howm-view-paragraph-region)) (x (point)) (old-file (buffer-file-name)) (s (buffer-substring-no-properties (car r) (second r)))) (when howm-mode (save-buffer) (kill-buffer (current-buffer)) (delete-file old-file) (howm-create-file) (howm-set-mode) (insert s) (goto-char x)))) (defun sacha/howm-delete () "Remove currently open file." (interactive) (let ((old-file (buffer-file-name))) (when howm-mode (save-buffer) (kill-buffer (current-buffer)) (delete-file old-file)))) (defvar sacha/howm-view-tags '("book")) (defun howm-view-tagged (dir &optional recursive-p) (howm-view-summary "" (howm-view-directory-items `(:tag ,sacha/howm-view-tags ,dir))) (when howm-ruby-mode-bug ;; sloppy! ;; (for old ruby-mode.el which sets global value of font-lock-keywords) (setq font-lock-keywords nil)) ) (defun howm-list-tagged () (interactive) (howm-set-command 'howm-list-tagged) (howm-view-tagged (car (howm-search-path)) t) (howm-list-normalize) ;; clean me [2004-07-11] (cond ((howm-list-title-p) t) ;; already done in (howm-list-normalize) (howm-list-all-title (howm-list-title)))) (add-to-list 'howm-list-title 'howm-list-tagged) (add-to-list 'howm-menu-display-rules '("%tags%" . "%here%(howm-menu-tags)")) (defun howm-menu-tags () (howm-menu-general "tags" nil (howm-tagged-menu 5 "book")))