1 ;;; howm-vars.el --- Wiki-like note-taking tool
2 ;;; Copyright (C) 2005-2018
3 ;;; HIRAOKA Kazuyuki <khi@users.osdn.me>
5 ;;; This program is free software; you can redistribute it and/or modify
6 ;;; it under the terms of the GNU General Public License as published by
7 ;;; the Free Software Foundation; either version 1, or (at your option)
10 ;;; This program is distributed in the hope that it will be useful,
11 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;;; GNU General Public License for more details.
15 ;;; The GNU General Public License is available by anonymouse ftp from
16 ;;; prep.ai.mit.edu in pub/gnu/COPYING. Alternately, you can write to
17 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
19 ;;--------------------------------------------------------------------
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 (defmacro howm-define-risky-command (risky orig)
27 "Define a macro RISKY which is risky-version of ORIG."
28 (let* ((gsymbol (cl-gensym))
30 (docstring (format "Do `%s' and set risky-local-variable property."
33 (,gsymbol &rest ,gargs)
35 (declare (indent 'defun))
36 (howm-define-risky-command-body ',orig ,gsymbol ,gargs))))
39 ;; I split this function from howm-define-risky-command for avoiding
40 ;; nested backquotes. Nested backquotes are byte-compiled to
41 ;; old-style-backquotes, that cause warnings when *.elc is loaded.
42 (cl-eval-when (compile load eval)
43 (defun howm-define-risky-command-body (command symbol args)
45 (,command ,symbol ,@args)
46 (put ',symbol 'risky-local-variable t))))
48 ;; ;; This code is byte-compiled to old-style-backquotes. Sigh...
49 ;; (defmacro howm-define-risky-command (risky orig)
50 ;; "Define a macro RISKY which is risky-version of ORIG."
51 ;; (let* ((gsymbol (cl-gensym))
52 ;; (gargs (cl-gensym))
53 ;; (docstring (format "Do `%s' and set risky-local-variable property."
56 ;; (put ',risky 'lisp-indent-hook 'defun)
58 ;; (,gsymbol &rest ,gargs)
60 ;; (let ((command ',orig)
64 ;; ;; (,',orig ...) doesn't work.
65 ;; ;; So I need to bind temporal variables outside nested backquote.
66 ;; (,command ,symbol ,@args)
67 ;; (put ',symbol 'risky-local-variable t)))))))
69 (howm-define-risky-command howm-defvar-risky defvar)
70 (howm-define-risky-command howm-defcustom-risky defcustom)
71 (howm-define-risky-command howm-defconst-risky defconst)
73 ;; ;; Should I use this?
74 ;; (defmacro howm-boundp-q (var)
77 ;; (howm-dont-warn-free-variable ,var)))
78 (defmacro howm-dont-warn-free-variable (var)
79 "No effect except for inhibition of warning in byte-compilation.
80 Without this trick, compiler says 'reference to free variable' even when
81 we have checked availability like (if (boundp xxx) ...)."
82 `(when (boundp (quote ,var))
85 (defmacro howm-funcall-if-defined (call &rest not-defined)
86 "Execute CALL if its car is defined as a function.
87 Otherwise, execute expressions in NOT-DEFINED.
88 This is cheat to avoid warning while byte-compilation.
89 Byte-compiler says \"not known to be defined\" even for codes like
90 (if (fboundp 'foo) (foo bar)).
92 \(macroexpand '(howm-funcall-if-defined (migemo-get-pattern roma) nil))
93 ==> (if (fboundp 'migemo-get-pattern)
94 (let ((howm-funcall-if-defined-f 'migemo-get-pattern))
95 (funcall howm-funcall-if-defined-f roma))
99 (let ((func (car call))
101 `(if (fboundp (quote ,func))
102 (let ((howm-funcall-if-defined-f (quote ,func)))
103 (funcall howm-funcall-if-defined-f ,@args))
106 ;; copied and modified from mule-cmds.el
107 ;; snap:///usr/share/emacs/21.2/lisp/international/mule-cmds.el#1870:(defun set-locale-environment (locale-name)
108 (defun howm-get-locale ()
109 (let ((vars '("LC_ALL" "LC_CTYPE" "LANG"))
111 (while (and vars (not (setq locale (getenv (car vars)))))
112 (setq vars (cdr vars)))
115 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
119 "Wiki-like note-taking tool."
120 :group 'applications)
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
125 (defvar howm-compatible-to-ver1dot3 nil
126 "If non-nil, compatible values to howm-1.3.* are used
127 as default of some variables; put (setq howm-compatible-to-ver1dot3 t)
128 *before* (require 'howm) if you like.")
130 (defgroup howm-compatibility nil
131 "Compatibility to howm-1.3.*."
134 (defmacro howm-if-ver1dot3 (oldval def)
136 (cl-destructuring-bind (command var val &rest args) def
137 `(,command ,var (if howm-compatible-to-ver1dot3 ,oldval ,val)
139 :group 'howm-compatibility)))
141 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144 (defgroup howm-files nil
145 "Names of files and directories."
148 (howm-defcustom-risky howm-directory "~/howm/"
149 "*All files under this directory are scanned recursively."
153 (let ((default-format "%Y/%m/%Y-%m-%d-%H%M%S.txt"))
154 (howm-if-ver1dot3 "%Y/%m/%Y-%m-%d-%H%M%S.howm"
155 (defcustom howm-file-name-format default-format
156 "Name of new file. See `format-time-string'.
157 For example, set as \"%Y/%m/%Y-%m-%d-%H%M%S.txt\" to separate each entry
158 to its own file. You must guarantee (string< oldfile newfile)."
159 :type `(radio (const :tag "One file for one entry" ,default-format)
160 (const :tag "One file for one day" "%Y/%m/%Y-%m-%d.txt")
161 (const :tag "One file for one month" "%Y/%Y-%m.txt")
162 (const :tag "One file for one year" "%Y.txt")
164 :group 'howm-efficiency
165 :group 'howm-files)))
167 (howm-defcustom-risky howm-keyword-file "~/.howm-keys"
168 "*Keywords (WikiNames) are stored in this file."
172 ;; inhibit warning in compilation.
173 (howm-dont-warn-free-variable image-file-name-regexps)
174 (defvar howm-image-file-name-regexps
175 (let ((exts-regexp "\\.\\(GIF\\|JP\\(?:E?G\\)\\|P\\(?:BM\\|GM\\|NG\\|PM\\)\\|TIFF?\\|X\\(?:[BP]M\\)\\|gif\\|jp\\(?:e?g\\)\\|p\\(?:bm\\|gm\\|ng\\|pm\\)\\|tiff?\\|x\\(?:[bp]m\\)\\)\\'")
176 (image-file-name-regexps (and (boundp 'image-file-name-regexps)
177 image-file-name-regexps)))
178 ;; copied from image-file-name-regexp.
179 (if image-file-name-regexps
182 (cons exts-regexp image-file-name-regexps)
183 image-file-name-regexps)
186 "Regular expression that matches image-file filenames.
187 Default value is equal to the result of `image-file-name-regexp'
190 In order to use `image-file-name-regexp' on Meadow 2.10 (ASAGAO),
191 max-specpdl-size must be increased from the default value 600.
192 Otherwise, an error occurs both in byte-compilation and in run time.
193 To avoid such troubles, this variable is prepared as a fixed string.")
195 (defvar howm-excluded-dirs '("RCS" "CVS" ".svn" ".git" "_darcs"))
197 (defvar howm-excluded-file-regexp-common-list
199 "\\.\\(bak\\|elc\\|gz\\|aux\\|toc\\|idx\\|dvi\\)$"
200 howm-image-file-name-regexps))
201 (defvar howm-excluded-file-regexp-dir-sep
202 (if (let ((case-fold-search t))
203 (string-match "windows" (symbol-name system-type)))
204 "[/\\\\]" ;; / or \ for win
207 (let ((dir-head (concat "\\(^\\|" howm-excluded-file-regexp-dir-sep "\\)"))
208 (excluded-dirs (concat (regexp-opt howm-excluded-dirs t)
209 howm-excluded-file-regexp-dir-sep)))
210 (let ((howm-excluded-file-regexp-dots-ok
211 (mapconcat #'identity
212 `(,(concat dir-head excluded-dirs)
214 ,@howm-excluded-file-regexp-common-list)
216 (howm-excluded-file-regexp-dots-ng
217 (mapconcat #'identity
218 `(,(concat dir-head "\\([.]\\|" excluded-dirs "\\)")
219 ,@howm-excluded-file-regexp-common-list)
221 (howm-defcustom-risky howm-excluded-file-regexp
222 howm-excluded-file-regexp-dots-ng
223 "Regexp for excluded files.
224 It is checked for relative paths from howm-directory and howm-search-path.
225 A file is excluded iff this regexp matches with all the relative paths."
226 :type `(radio (const :tag "Don't search dot files"
227 ,howm-excluded-file-regexp-dots-ng)
228 (const :tag "Search dot files"
229 ,howm-excluded-file-regexp-dots-ok)
234 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
237 (defgroup howm-menu nil
241 (defcustom howm-menu-lang
242 (let ((lang-table '((fr "French" "^fr")
243 (ja "Japanese" "^ja"))))
244 (let ((lang (or (and (boundp 'current-language-environment)
245 current-language-environment)
247 (locale (howm-get-locale))
250 (if (or (string= lang (cadr rule))
251 (string-match (cl-caddr rule) locale))
252 (setq ret (car rule))))
256 :type '(radio (const en) (const fr) (const ja))
259 (howm-defcustom-risky howm-menu-file nil
260 "*Specify menu file explicitly, or set as nil to search every time."
261 :type '(radio (const :tag "Search every time" nil)
262 (const "0000-00-00-000000.txt")
265 :group 'howm-efficiency
268 (defcustom howm-menu-expiry-hours 0
269 "*Cache menu contents for this number of hours."
271 :group 'howm-efficiency
274 (defcustom howm-menu-refresh-after-save t
275 "*If non-nil, refresh menu contents after you save howm note."
277 :group 'howm-efficiency
280 (defcustom howm-menu-name-format "*howmM:%s*"
281 "*Name format of menu buffer."
282 :type '(radio (const :tag "Never show in normal buffer list" " *howmM:%s*")
286 (defcustom howm-menu-footer nil
287 "Footer string for each menu. Nil means no footer."
288 :type '(radio (const :tag "Off" nil)
292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
295 (defgroup howm-reminder nil
296 "Schedule and todo list."
299 (defvar howm-reminder-old-format nil)
301 (defvar howm-reminder-marks
302 ;; Be careful to order of characters.
303 ;; "-" must be first so that regexp "[-+~!@.]" makes sense.
304 (if howm-reminder-old-format "-+~!@. " "-+~!@."))
305 (defvar howm-reminder-types
306 (format "[%s]" howm-reminder-marks))
308 (defun howm-custom-reminder-get-types (symbol)
309 (let ((reg (default-value symbol))
310 (default-types (split-string howm-reminder-marks "")))
311 ;; return list of types for standard cases
312 ;; and string itself for nonstandard cases
313 (if (not (string-match "^\\[\\(.*\\)\\]" reg))
315 (let ((types (split-string (match-string-no-properties 1 reg) "")))
316 (if (cl-find-if-not (lambda (x) (member x default-types))
319 (cl-remove-if-not (lambda (x) (member x types))
321 (defun howm-custom-reminder-set-types (symbol types)
323 (setq types (apply #'concat `("[" ,@types "]"))))
324 (set-default symbol types))
325 (defun howm-custom-reminder-list-types ()
326 `(radio (set ,@(mapcar (lambda (ty) (list 'const ty))
327 (split-string howm-reminder-marks "")))
330 (defcustom howm-schedule-types "[!@.]"
331 "*Regular expression of reminder types which are listed as schedule."
332 :get #'howm-custom-reminder-get-types
333 :set #'howm-custom-reminder-set-types
334 :type (howm-custom-reminder-list-types)
335 :group 'howm-efficiency
336 :group 'howm-reminder)
338 (defcustom howm-todo-types
339 (if howm-reminder-old-format "[-+~! .]" "[-+~!.]")
340 "*Regular expression of reminder types which are listed as todo."
341 :get #'howm-custom-reminder-get-types
342 :set #'howm-custom-reminder-set-types
343 :type (howm-custom-reminder-list-types)
344 :group 'howm-efficiency
345 :group 'howm-reminder)
347 (defcustom howm-congrats-format '("Finished %s tasks!")
348 "List of format strings to generate message when a reminder is finished.
349 One of elements is chosen randomly every time."
350 :type '(repeat string)
351 :group 'howm-reminder)
353 (howm-defcustom-risky howm-congrats-command nil
354 "*If non-nil, this command is executed when a reminder is finished.
355 Example: (\"play\" \"~/sound/fanfare.wav\") for calling the command
356 \"play ~/sound/fanfare.wav\"."
357 :type '(repeat string)
358 :group 'howm-reminder)
360 (defcustom howm-reminder-cancel-string "cancel"
361 "*This string is inserted automatically when a reminder is canceled."
363 :group 'howm-reminder)
365 (defcustom howm-action-lock-forward-save-buffer nil
366 "*Non nil if direct manipulation on reminder list should cause auto-save."
368 :group 'howm-reminder)
370 (defcustom howm-action-lock-forward-kill-buffer nil
371 "*Non nil if direct manipulation on reminder list should cause kill-buffer.
372 Be careful that you cannot undo the result of action-lock after kill-buffer."
374 :group 'howm-reminder)
377 (defcustom howm-action-lock-forward-fuzziness 5
378 "*Maximum lines of permitted inconsistency for `howm-action-lock-forward'."
380 :group 'howm-reminder))
382 (let* ((sep "- - - - - - - - - - - - - - - - - - -")
383 (reminder-default `((-1 . ,sep) (0 . ,sep) (nil . ,sep)))
384 (todo-default `((0 . ,sep) (nil . ,sep))))
385 (howm-if-ver1dot3 nil
386 (defcustom howm-menu-reminder-separators reminder-default
387 "Assoc list to specify positions and strings of separators in reminder
388 in menu. For each element, car is days from now, and cdr is separator string.
389 If car is nil, it means the border between schedule and todo.
390 This option is prepared for `howm-menu-reminder'."
391 :type `(radio (const :tag "No separators" nil)
392 (const :tag "Default separators" ,reminder-default)
395 (const :tag "Between schedule and todo" nil))
397 :group 'howm-reminder))
398 (defcustom howm-todo-separators nil
399 "Assoc list to specify positions and strings of separators in todo buffer.
400 For each element, car is priority and cdr is separator string.
401 If car is nil, it means the border between active and sleeping reminders."
402 :type `(radio (const :tag "No separators" nil)
403 (const :tag "Default separators" ,todo-default)
404 (alist :key-type number
406 :group 'howm-reminder))
408 (howm-if-ver1dot3 nil
409 (defcustom howm-schedule-sort-by-time t
410 "Non nil if `howm-schedule-sort-converter' should consider time part."
412 :group 'howm-reminder))
414 (defcustom howm-reminder-menu-types
415 (if howm-reminder-old-format "[-+~!@ ]" "[-+~!@]")
416 "*Regular expression of reminder types which are shown in menu."
417 :get #'howm-custom-reminder-get-types
418 :set #'howm-custom-reminder-set-types
419 :type (howm-custom-reminder-list-types)
420 :group 'howm-reminder)
426 (defgroup howm-menu-reminder nil
427 "Reminders shown in menu."
429 :group 'howm-reminder)
431 (defcustom howm-schedule-menu-types "[!@]"
432 "*Regular expression of reminder types which are shown in menu as schedule."
433 :get #'howm-custom-reminder-get-types
434 :set #'howm-custom-reminder-set-types
435 :type (howm-custom-reminder-list-types)
436 :group 'howm-efficiency
437 :group 'howm-menu-reminder)
439 (defcustom howm-todo-menu-types
440 (if howm-reminder-old-format "[-+~! .]" "[-+~!.]")
441 "*Regular expression of reminder types which are shown in menu as todo."
442 :get #'howm-custom-reminder-get-types
443 :set #'howm-custom-reminder-set-types
444 :type (howm-custom-reminder-list-types)
445 :group 'howm-efficiency
446 :group 'howm-menu-reminder)
448 (defcustom howm-menu-schedule-days 7
449 "*Show schedule in menu until this number of days from now."
451 :group 'howm-menu-reminder)
453 (defcustom howm-menu-schedule-days-before 0
454 "*Show schedule in menu from this number of days ago."
456 :group 'howm-menu-reminder)
458 (defcustom howm-menu-todo-num 50
459 "*Maximum number of todo items shown in menu."
461 :group 'howm-menu-reminder)
463 (defvar howm-huge- 66666)
464 (defvar howm-huge 77777)
465 (defvar howm-huge+ 88888)
466 (defvar howm-huge++ 99999)
468 (defcustom howm-menu-todo-priority (- howm-huge+)
469 "*Limit priority for elimination of reminders in menu."
470 :type `(radio (const :tag "Show sleeping reminders",(- howm-huge+))
471 (const :tag "Hide sleeping reminders" ,(- howm-huge-))
473 :group 'howm-menu-reminder)
475 (defcustom howm-todo-priority-done-bottom (- howm-huge+)
476 "*Base priority of done reminder.
477 <priority of done reminder> = <this value> + <days from specified date>"
478 :type `(radio (const :tag "Deeper than sleeping reminders" ,(- howm-huge+))
479 (const :tag "Shallower than sleeping reminders"
482 :group 'howm-menu-reminder)
484 (defcustom howm-menu-recent-num 20
485 "*Maximum number of recent items shown in menu."
487 :group 'howm-menu-reminder)
489 (defcustom howm-menu-recent-regexp nil
490 "Regexp which is regarded as title line in recent list in menu.
491 When it is nil, `howm-view-title-regexp' is used."
492 :type '(radio (const :tag "Default" nil)
495 :group 'howm-menu-reminder)
497 (defcustom howm-menu-todo-priority-format nil
498 "*Format for priority display in todo list in menu, or nil for no display."
499 :type '(radio (const :tag "Off" nil)
503 :group 'howm-menu-reminder)
505 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
508 (defgroup howm-list nil
509 "Style of list view."
512 (defcustom howm-view-contents-limit nil
513 "*Max length for howm-view-contents. Nil means no limit."
514 :type '(radio (const :tag "No limit" nil)
518 (defcustom howm-view-summary-keep-cursor t
519 "*If non-nil, keep cursor position when you open a note from summary list."
523 (defcustom howm-view-summary-omit-same-name t
524 "*If non-nil, same name is not written repeatedly in summary list."
528 (defcustom howm-list-recent-days 7
529 "*This number of days are listed by `howm-list-recent'."
533 (defcustom howm-list-buffers-exclude
534 '("*Messages*" ".howm-keys" ".howm-history")
535 "*List of excluded buffer names for `howm-list-buffers'."
536 :type '(repeat string)
543 (defgroup howm-sort nil
544 "Sorting and filtering of matched entries."
547 (howm-defcustom-risky howm-list-normalizer nil
548 "*Obsolete. Use `howm-normalizer' insteadly."
549 :type '(radio (const :tag "Off (strongly recommended)" nil)
550 (function-item :tag "Sort by edit-time"
551 howm-view-sort-by-mtime)
552 (function-item :tag "Sort by create-time"
553 howm-view-sort-by-reverse-date)
557 (howm-defcustom-risky howm-normalizer 'howm-sort-items-by-mtime
558 "*Default method to list matched notes.
559 For backward compatibility, this value is overridden
560 if `howm-list-normalizer' is non-nil."
561 :type '(radio (function-item :tag "Sort by edit-time"
562 howm-sort-items-by-mtime)
563 (function-item :tag "Sort by create-time"
564 howm-sort-items-by-reverse-date)
568 (defcustom howm-list-prefer-word nil
569 "*Matches to whole word are listed first in summary buffer."
573 (defcustom howm-list-prefer-wiki t
574 "*Matches to wiki tags are listed first in summary buffer."
582 (defgroup howm-title nil
583 "Title of each entry."
586 ;; I don't know the way to generate this list automatically. Sigh...
587 (defvar howm-custom-command-list
588 `(set ,@(mapcar (lambda (com) (list 'const com))
597 howm-action-lock-date-search
600 (howm-defcustom-risky howm-list-title
605 ; howm-keyword-search
606 ; howm-list-grep howm-list-grep-fixed howm-list-migemo
608 howm-action-lock-date-search
610 "List of commands in which titles are listed instead of matched lines.
612 If it is a function, the evaluated value is used instead of itself."
613 :type `(radio (const :tag "Always" t)
614 (const :tag "Never" nil)
615 ,howm-custom-command-list
616 ;; (set (const howm-list-all)
617 ;; (const howm-list-recent)
618 ;; (const howm-list-around)
619 ;; (const howm-keyword-search)
620 ;; (const howm-list-grep)
621 ;; (const howm-list-grep-fixed)
622 ;; (const howm-list-migemo)
623 ;; (const howm-list-related))
625 :group 'howm-efficiency
628 (defcustom howm-list-title-regexp nil
629 "Regexp which is regarded as title line in summary buffer.
630 When it is nil, `howm-view-title-regexp' is used."
631 :type '(radio (const :tag "Default" nil)
635 (defcustom howm-list-title-undo t
636 "*Non-nil if `howm-list-toggle-title' should toggle whether title is shown
639 :group 'howm-efficiency
646 (defgroup howm-list-bufwin nil
647 "Buffers and windows for listing search result."
650 (defcustom howm-view-summary-name "*howmS*"
651 "Format string of buffer name for summary.
652 %s is replaced with searched string. See `format'."
653 :type '(radio (const :tag "Use one common buffer" "*howmS*")
654 (const :tag "Make new buffer for each search" "*howmS:%s*")
656 :group 'howm-list-bufwin)
658 (defcustom howm-view-contents-name "*howmC*"
659 "Format string of buffer name for contents.
660 %s is replaced with searched string. See `format'."
661 :type '(radio (const :tag "Use one common buffer" "*howmC*")
662 (const :tag "Make new buffer for each search" "*howmC:%s*")
664 :group 'howm-list-bufwin)
666 (howm-defcustom-risky howm-view-summary-persistent t
667 "*If non-nil, keep summary buffer on howm-view-summary-open by default.
668 If it is a function, the evaluated value is used instead of itself."
670 :group 'howm-list-bufwin)
672 (howm-defcustom-risky howm-view-contents-persistent t
673 "*If non-nil, keep contents buffer on howm-view-contents-open by default.
674 If it is a function, the evaluated value is used instead of itself."
676 :group 'howm-list-bufwin)
678 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
681 (defgroup howm-search nil
685 (defcustom howm-keyword-case-fold-search nil
686 "*Non-nil if searches of come-from keywords should ignore case."
690 (defcustom howm-check-word-break nil
691 "*Non-nil if come-from keywords within a word should not linked.
692 When the value is a string (regexp), word breaks are checked
693 only for matched keywords. "
694 :type '(radio (const :tag "Always" t)
695 (const :tag "Never" nil)
696 (const :tag "ASCII only" "^[[:ascii:]]+$")
700 (defcustom howm-view-update-search-ring nil
701 "*Non-nil if search-ring should be updated in howm search."
705 (defcustom howm-message-time nil
706 "*Non nil if search etc. should show took time."
711 (howm-defcustom-risky howm-history-file "~/.howm-history"
712 "*Search history is recorded to that file."
717 (defcustom howm-history-limit 50
718 "*Limit number of recorded search history, or nil for no limit.
719 Set 0 to inhibit recording."
720 :type '(radio (const :tag "No limit" nil)
724 (defcustom howm-history-unique t
725 "*If non-nil, duplicated entries are removed from search history."
729 (defcustom howm-keyword-list-alias-sep "\t"
730 "*Separator string for alias keywords in the keyword file `howm-keyword-file'.
731 If it is nil, alias of come-from keyword is disabled."
732 :type '(radio (const :tag "Disable aliases" nil)
733 (const :tag "Tab" "\t")
737 (defcustom howm-keyword-aliases-recursive t
738 "*Non nil if aliases of come-from keywords should be expanded recursively."
746 (defgroup howm-grep nil
747 "Use external grep command for fast search."
748 :group 'howm-efficiency
751 (howm-defcustom-risky howm-view-use-grep nil
752 "*If non-nil, use external grep command for search.
753 Performance must be improved greatly if you set this.
754 When the value is elisp function, it is used instead of `howm-fake-grep'."
755 :type '(radio (const :tag "On" t)
756 (const :tag "Off" nil)
760 ;; These variables should be renamed: howm-view-xxx ==> howm-xxx.
761 (howm-defcustom-risky howm-view-grep-command "grep"
762 "*Command name for grep."
765 (howm-defvar-risky howm-view-fgrep-command nil
766 "*Command name for fgrep.
767 This variable is obsolete and may be removed in future.")
768 (defvar howm-view-grep-default-option
769 ;; "labels" causes a trouble in git-head emacs (d5e3922) [2015-01-31]
770 (let* ((ed (lambda (d) (concat "--exclude-dir=" d)))
771 (has-ed (condition-case nil
772 (eq 0 (call-process howm-view-grep-command nil nil nil
773 (apply ed "/") "--version"))
775 (opts (cons "-Hnr" (and has-ed (mapcar ed howm-excluded-dirs)))))
776 (mapconcat #'identity opts " ")))
777 (howm-defcustom-risky howm-view-grep-option howm-view-grep-default-option
778 "*Common grep option for howm."
779 :type `(radio (const :tag "scan all files"
780 ,howm-view-grep-default-option)
781 (const :tag "scan *.howm only"
782 ,(concat howm-view-grep-default-option
783 " --include=*.howm"))
786 (howm-defcustom-risky howm-view-grep-extended-option "-E"
787 "*Grep option for extended regular expression."
790 (howm-defcustom-risky howm-view-grep-fixed-option "-F"
791 "*Grep option to search fixed strings."
794 (howm-defcustom-risky howm-view-grep-ignore-case-option "-i"
795 "*Grep option for ignoring case distinctions."
798 (howm-defcustom-risky howm-view-grep-expr-option "-e"
799 "*Grep option for pattern."
802 (howm-defcustom-risky howm-view-grep-file-stdin-option "-f -"
803 "*Grep option for receiving patterns from standard input.
804 If this is nil, pattern is received as command line argument."
805 :type '(radio (const :tag "Off" nil)
809 (howm-defcustom-risky howm-command-length-limit 10000
810 "*Maximum length of command line for call-process."
814 (defcustom howm-process-coding-system nil
815 "*Default coding system for grep command in howm.
816 If the value is a symbol, it is used for both read and write.
817 If the value is a cons pair, its car and cdr are used for read and write,
821 (setq howm-process-coding-system 'euc-japan-unix)
822 (setq howm-process-coding-system '(utf-8-unix . sjis-unix))"
823 :type '(radio (const :tag "Off" nil)
825 (cons coding-system coding-system))
828 (howm-if-ver1dot3 nil
829 (defcustom howm-occur-force-fake-grep t
830 "*If non-nil, force `howm-occur' to use `howm-fake-grep'
831 so that highlighting works correctly."
835 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
838 (defgroup howm-misc nil
839 "Miscellaneous customization."
842 (defvar howm-prefix "\C-c,"
843 "Howm commands are invoked by this prefix + some keys.")
845 (defcustom howm-random-walk-wait 2
846 "*Seconds of wait in `howm-random-walk'."
850 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
853 (defgroup howm-create nil
857 (defcustom howm-prepend nil
858 "*Non nil if new entries should be prepended to previous entries.
859 Otherwise, they are appended."
860 :type '(radio (const :tag "Append" nil)
861 (const :tag "Prepend" t))
864 (defcustom howm-content-from-region nil
865 "*When the value non-nil, selected string is inserted as default content.
866 Unless the value is t, single-line selection is inserted as title instead.
867 This variable is ignored when `transient-mark-mode' is nil."
868 :type '(radio (const :tag "Off" nil)
869 (const :tag "Single line selection is copied as title" 1)
870 (const :tag "Any selection is copied as content" t))
873 (defcustom howm-title-from-search nil
874 "*Non nil if searched keyword is inserted as default title
875 when `howm-create' is called on summary buffer."
879 (defcustom howm-create-here-just nil
880 "*Non nil if `howm-create-here' should insert new entry into cursor position
881 rather than append or prepend."
882 :type '(radio (const :tag "Append or prepend" nil)
883 (const :tag "Just here" t))
886 (defcustom howm-remember-first-line-to-title nil
887 "If non-nil, the first line in `howm-remember' is set to %title
888 and the rest lines are inserted to the position at %cursor in `howm-template.
889 If nil, all the lines are simply inserted at %cursor."
893 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
896 (defgroup howm-viewer nil
897 "External viewers for images, movies, sounds, etc."
900 (defun howm-try-require (feature)
901 (and (locate-library (symbol-name feature))
904 ;; These variables should be renamed.
906 (howm-defcustom-risky howm-view-external-viewer-assoc nil
907 "List of viewer specifications.
908 Each specification must be a cons pair of type and format.
909 Type is a regular expression of file names.
910 Format is a command string in which %s is replaced with file name.
911 This setting is prior to mailcap.
913 This variable is marked as a risky local variable
914 because `howm-viewer-dispatchers' `howm-viewer-indicator'
915 and `howm-viewer-type' accept functions instead of format strings.
918 (setq howm-view-external-viewer-assoc
920 (\"[.]\\(jpg\\|gif\\|png\\)$\" . \"display %s\")
921 (\"[.]dvi$\" . \"xdvi %s\")
924 :type '(alist :key-type regexp :value-type string)
927 (defcustom howm-view-use-mailcap
928 (and (howm-try-require 'mailcap)
929 (fboundp 'mailcap-parse-mailcaps)
930 (fboundp 'mailcap-parse-mimetypes))
931 "*Non nil if external viewers should be selected according to mailcap.
932 Mailcap processing depends on gnus/mailcap, and old FLIM library may
937 (defcustom howm-view-open-by-myself '("text/.*" "application/emacs-lisp")
938 "List of regular expressions for mime types which should be opened normally."
939 :type '(repeat regexp)
942 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
945 (defgroup howm-narrow nil
946 "Narrowing to each entry."
949 (defcustom howm-auto-narrow t
950 "List of commands after which the function `howm-auto-narrow' can work.
951 If the value is t, it means 'always'."
952 :type `(radio (const :tag "Never" nil)
953 (const :tag "Always" t)
954 ,howm-custom-command-list)
957 (mapc (lambda (hook) (custom-add-option hook 'howm-auto-narrow))
958 '(howm-view-open-hook howm-create-hook))
960 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
963 (defgroup howm-efficiency nil
964 "To improve performance, use grep and turn off expensive options."
967 (defcustom howm-refresh-after-save t
968 "*Redraw links after you save howm note."
970 :group 'howm-efficiency)
972 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
975 (defgroup howm-faces nil
980 (howm-defcustom-risky howm-user-font-lock-keywords nil
981 "Font lock keywords for all howm-related buffers.
982 See help of `font-lock-keywords' for details.
983 Note: `howm-menu-font-lock-rules' overrides this variable."
984 ;; :type '(repeat (radio (cons regexp (list (const quote) face))
989 (defcustom howm-use-color t
990 "*If non-nil, highlight tags in howm-mode verbosely."
994 (defface howm-view-hilit-face
995 '((((class color)) (:foreground "red"))
997 "*Face for matched word."
1000 (defface howm-view-name-face
1001 '((((class color)) (:foreground "white" :background "blue"))
1003 "*Face for file name in summary buffer."
1006 (defface howm-view-empty-face
1007 '((((class color)) (:background "midnight blue"))
1009 "*Face for empty field in summary buffer."
1012 (defface howm-mode-title-face ;; =
1013 '((((class color)) (:foreground "RoyalBlue"))
1017 (defface howm-mode-ref-face ;; >>>
1018 '((((class color) (background light)) (:foreground "blue"))
1019 (((class color) (background dark)) (:foreground "cyan"))
1021 "*Face for goto link."
1023 (defface howm-mode-keyword-face ;; <<<
1024 '((((class color)) (:foreground "white" :background "blue"))
1026 "*Face for come-from link."
1028 (defface howm-mode-wiki-face ;; [[]]
1029 '((((class color) (background light)) (:foreground "blue"))
1030 (((class color) (background dark)) (:foreground "cyan"))
1032 "*Face for wiki link."
1035 (defface howm-reminder-normal-face
1036 '((((class color)) (:foreground "blue"))
1038 "*Face for normal reminder."
1040 (defface howm-reminder-todo-face
1041 '((((class color) (background light)) (:foreground "purple"))
1042 (((class color) (background dark)) (:foreground "yellow"))
1046 (defface howm-reminder-defer-face
1047 '((((class color)) (:foreground "magenta"))
1051 (defface howm-reminder-deadline-face
1052 '((((class color)) (:foreground "red"))
1054 "*Face for deadline."
1056 (defface howm-reminder-late-deadline-face
1057 '((((class color)) (:background "red" :foreground "black"))
1059 "*Face for late deadline."
1061 (defface howm-reminder-schedule-face
1062 '((((class color) (background light)) (:foreground "dark green"))
1063 (((class color) (background dark)) (:foreground "green"))
1065 "*Face for schedule."
1067 (defface howm-reminder-done-face
1068 '((((class color) (background light)) ())
1069 (((class color) (background dark)) (:foreground "gray"))
1071 "*Face for done reminder."
1073 (defface howm-reminder-today-face
1074 '((((class color)) (:foreground "black" :background "orange"))
1078 (defface howm-reminder-tomorrow-face
1079 '((((class color)) (:foreground "black" :background "pink"))
1081 "*Face for tommorow."
1084 (defface howm-menu-list-face ;; item header in menu-mode list (schedule, todo)
1086 "*Face for list in menu."
1088 (defface howm-menu-key-face ;; shortcut key in menu-mode
1089 '((((class color) (background light)) (:foreground "dark red"))
1090 (((class color) (background dark)) (:foreground "orange"))
1092 "*Face for key binding in menu."
1095 (defvar howm-view-hilit-face 'howm-view-hilit-face
1096 "*Face for matched word.")
1097 (defvar howm-view-name-face 'howm-view-name-face
1098 "*Face for file name in summary buffer.")
1099 (defvar howm-view-empty-face 'howm-view-empty-face
1100 "*Face for empty field in summary buffer.")
1101 (defvar howm-mode-title-face 'howm-mode-title-face
1103 (defvar howm-mode-ref-face 'howm-mode-ref-face
1104 "*Face for goto link.")
1105 (defvar howm-mode-keyword-face 'howm-mode-keyword-face
1106 "*Face for come-from link.")
1107 (defvar howm-mode-wiki-face 'howm-mode-wiki-face
1108 "*Face for wiki link.")
1109 (defvar howm-reminder-normal-face 'howm-reminder-normal-face
1110 "*Face for normal reminder.")
1111 (defvar howm-reminder-todo-face 'howm-reminder-todo-face
1113 (defvar howm-reminder-defer-face 'howm-reminder-defer-face
1115 (defvar howm-reminder-deadline-face 'howm-reminder-deadline-face
1116 "*Face for deadline.")
1117 (defvar howm-reminder-late-deadline-face 'howm-reminder-late-deadline-face
1118 "*Face for late deadline.")
1119 (defvar howm-reminder-schedule-face 'howm-reminder-schedule-face
1120 "*Face for schedule.")
1121 (defvar howm-reminder-done-face 'howm-reminder-done-face
1122 "*Face for done reminder.")
1123 (defvar howm-reminder-today-face 'howm-reminder-today-face
1125 (defvar howm-reminder-tomorrow-face 'howm-reminder-tomorrow-face
1126 "*Face for tommorow.")
1127 (defvar howm-menu-list-face 'howm-menu-list-face
1128 "*Face for list in menu.")
1129 (defvar howm-menu-key-face 'howm-menu-key-face
1130 "*Face for key binding in menu.")
1132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1135 (defgroup howm-hooks nil
1139 (defcustom howm-mode-hook nil
1140 "Hook run at the end of function `howm-mode'"
1144 (defcustom howm-mode-on-hook nil
1145 "Hook run when `howm-mode' is turned on."
1149 (defcustom howm-mode-off-hook nil
1150 "Hook run when `howm-mode' is turned off."
1154 (defcustom howm-view-open-hook nil
1155 "Hook run when open a note from summary/contents buffer."
1160 (defcustom howm-view-before-open-hook nil
1161 "Hook run before open something from summary or contents buffer."
1165 (defcustom howm-create-file-hook nil
1166 "Hook run when buffer for new note is created."
1170 (defcustom howm-create-hook nil
1171 "Hook run after new note is created and set up."
1176 (defcustom howm-menu-hook nil
1177 "Hook run at the end of `howm-menu-refresh'."
1181 (defcustom howm-congrats-hook nil
1182 "Hook run at the end of `howm-congrats'."
1186 (defcustom howm-after-save-hook nil
1187 "Hook run at the end of `howm-after-save'."
1191 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1194 (defgroup howm-devel nil
1195 "Developers' diagnoses."
1198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1201 (defgroup howm-experimental nil
1202 "Test of experimental features."
1205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1206 ;; Date format (need refactoring)
1208 (defvar howm-date-separator "-") ;; "-" ==> 2003-10-21
1210 ;; Fix me: redundant (howm-date-* & howm-reminder-*)
1211 ;; (cf.) howm-reminder-regexp-grep-* howm-reminder-today-format
1212 (defvar howm-date-regexp-grep
1213 (concat "[1-2][0-9][0-9][0-9]" howm-date-separator
1214 "[0-1][0-9]" howm-date-separator
1216 (defvar howm-date-regexp
1217 (concat "\\([1-2][0-9][0-9][0-9]\\)" howm-date-separator
1218 "\\([0-1][0-9]\\)" howm-date-separator
1219 "\\([0-3][0-9]\\)"))
1220 (defvar howm-date-regexp-year-pos 1)
1221 (defvar howm-date-regexp-month-pos 2)
1222 (defvar howm-date-regexp-day-pos 3)
1223 (defvar howm-date-format
1224 (concat "%Y" howm-date-separator "%m" howm-date-separator "%d"))
1225 (defvar howm-dtime-body-format
1226 (concat howm-date-format " %H:%M"))
1227 (defvar howm-dtime-format
1228 (concat "[" howm-dtime-body-format "]"))
1229 (defvar howm-insert-date-format "[%s]")
1230 (defvar howm-insert-date-future nil)
1232 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1233 ;; Avoid reference to free variable (need refactoring)
1235 (howm-defvar-risky howm-menu-action-arg 'howm-menu-action-arg-name)
1239 (provide 'howm-vars)
1241 ;;; howm-vars.el ends here