1 ;;; howm-vars.el --- Wiki-like note-taking tool
2 ;;; Copyright (C) 2005-2018
3 ;;; HIRAOKA Kazuyuki <khi@users.osdn.me>
4 ;;; $Id: howm-vars.el,v 1.59 2011-12-31 15:07:29 hira Exp $
6 ;;; This program is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 1, or (at your option)
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; The GNU General Public License is available by anonymouse ftp from
17 ;;; prep.ai.mit.edu in pub/gnu/COPYING. Alternately, you can write to
18 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
20 ;;--------------------------------------------------------------------
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 (defmacro howm-define-risky-command (risky orig)
28 "Define a macro RISKY which is risky-version of ORIG."
29 (let* ((gsymbol (cl-gensym))
31 (docstring (format "Do `%s' and set risky-local-variable property."
34 (,gsymbol &rest ,gargs)
36 (declare (indent 'defun))
37 (howm-define-risky-command-body ',orig ,gsymbol ,gargs))))
40 ;; I split this function from howm-define-risky-command for avoiding
41 ;; nested backquotes. Nested backquotes are byte-compiled to
42 ;; old-style-backquotes, that cause warnings when *.elc is loaded.
43 (cl-eval-when (compile load eval)
44 (defun howm-define-risky-command-body (command symbol args)
46 (,command ,symbol ,@args)
47 (put ',symbol 'risky-local-variable t))))
49 ;; ;; This code is byte-compiled to old-style-backquotes. Sigh...
50 ;; (defmacro howm-define-risky-command (risky orig)
51 ;; "Define a macro RISKY which is risky-version of ORIG."
52 ;; (let* ((gsymbol (cl-gensym))
53 ;; (gargs (cl-gensym))
54 ;; (docstring (format "Do `%s' and set risky-local-variable property."
57 ;; (put ',risky 'lisp-indent-hook 'defun)
59 ;; (,gsymbol &rest ,gargs)
61 ;; (let ((command ',orig)
65 ;; ;; (,',orig ...) doesn't work.
66 ;; ;; So I need to bind temporal variables outside nested backquote.
67 ;; (,command ,symbol ,@args)
68 ;; (put ',symbol 'risky-local-variable t)))))))
70 (howm-define-risky-command howm-defvar-risky defvar)
71 (howm-define-risky-command howm-defcustom-risky defcustom)
72 (howm-define-risky-command howm-defconst-risky defconst)
74 ;; ;; Should I use this?
75 ;; (defmacro howm-boundp-q (var)
78 ;; (howm-dont-warn-free-variable ,var)))
79 (defmacro howm-dont-warn-free-variable (var)
80 "No effect except for inhibition of warning in byte-compilation.
81 Without this trick, compiler says 'reference to free variable' even when
82 we have checked availability like (if (boundp xxx) ...)."
83 `(when (boundp (quote ,var))
86 (defmacro howm-funcall-if-defined (call &rest not-defined)
87 "Execute CALL if its car is defined as a function.
88 Otherwise, execute expressions in NOT-DEFINED.
89 This is cheat to avoid warning while byte-compilation.
90 Byte-compiler says \"not known to be defined\" even for codes like
91 (if (fboundp 'foo) (foo bar)).
93 \(macroexpand '(howm-funcall-if-defined (migemo-get-pattern roma) nil))
94 ==> (if (fboundp 'migemo-get-pattern)
95 (let ((howm-funcall-if-defined-f 'migemo-get-pattern))
96 (funcall howm-funcall-if-defined-f roma))
100 (let ((func (car call))
102 `(if (fboundp (quote ,func))
103 (let ((howm-funcall-if-defined-f (quote ,func)))
104 (funcall howm-funcall-if-defined-f ,@args))
107 ;; copied and modified from mule-cmds.el
108 ;; snap:///usr/share/emacs/21.2/lisp/international/mule-cmds.el#1870:(defun set-locale-environment (locale-name)
109 (defun howm-get-locale ()
110 (let ((vars '("LC_ALL" "LC_CTYPE" "LANG"))
112 (while (and vars (not (setq locale (getenv (car vars)))))
113 (setq vars (cdr vars)))
116 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
120 "Wiki-like note-taking tool."
121 :group 'applications)
123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126 (defvar howm-compatible-to-ver1dot3 nil
127 "If non-nil, compatible values to howm-1.3.* are used
128 as default of some variables; put (setq howm-compatible-to-ver1dot3 t)
129 *before* (require 'howm) if you like.")
131 (defgroup howm-compatibility nil
132 "Compatibility to howm-1.3.*."
135 (defmacro howm-if-ver1dot3 (oldval def)
137 (cl-destructuring-bind (command var val &rest args) def
138 `(,command ,var (if howm-compatible-to-ver1dot3 ,oldval ,val)
140 :group 'howm-compatibility)))
142 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
145 (defgroup howm-files nil
146 "Names of files and directories."
149 (howm-defcustom-risky howm-directory "~/howm/"
150 "*All files under this directory are scanned recursively."
154 (let ((default-format "%Y/%m/%Y-%m-%d-%H%M%S.txt"))
155 (howm-if-ver1dot3 "%Y/%m/%Y-%m-%d-%H%M%S.howm"
156 (defcustom howm-file-name-format default-format
157 "Name of new file. See `format-time-string'.
158 For example, set as \"%Y/%m/%Y-%m-%d-%H%M%S.txt\" to separate each entry
159 to its own file. You must guarantee (string< oldfile newfile)."
160 :type `(radio (const :tag "One file for one entry" ,default-format)
161 (const :tag "One file for one day" "%Y/%m/%Y-%m-%d.txt")
162 (const :tag "One file for one month" "%Y/%Y-%m.txt")
163 (const :tag "One file for one year" "%Y.txt")
165 :group 'howm-efficiency
166 :group 'howm-files)))
168 (howm-defcustom-risky howm-keyword-file "~/.howm-keys"
169 "*Keywords (WikiNames) are stored in this file."
173 ;; inhibit warning in compilation.
174 (howm-dont-warn-free-variable image-file-name-regexps)
175 (defvar howm-image-file-name-regexps
176 (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\\)\\)\\'")
177 (image-file-name-regexps (and (boundp 'image-file-name-regexps)
178 image-file-name-regexps)))
179 ;; copied from image-file-name-regexp.
180 (if image-file-name-regexps
183 (cons exts-regexp image-file-name-regexps)
184 image-file-name-regexps)
187 "Regular expression that matches image-file filenames.
188 Default value is equal to the result of `image-file-name-regexp'
191 In order to use `image-file-name-regexp' on Meadow 2.10 (ASAGAO),
192 max-specpdl-size must be increased from the default value 600.
193 Otherwise, an error occurs both in byte-compilation and in run time.
194 To avoid such troubles, this variable is prepared as a fixed string.")
196 (defvar howm-excluded-dirs '("RCS" "CVS" ".svn" ".git" "_darcs"))
198 (defvar howm-excluded-file-regexp-common-list
200 "\\.\\(bak\\|elc\\|gz\\|aux\\|toc\\|idx\\|dvi\\)$"
201 howm-image-file-name-regexps))
202 (defvar howm-excluded-file-regexp-dir-sep
203 (if (let ((case-fold-search t))
204 (string-match "windows" (symbol-name system-type)))
205 "[/\\\\]" ;; / or \ for win
208 (let ((dir-head (concat "\\(^\\|" howm-excluded-file-regexp-dir-sep "\\)"))
209 (excluded-dirs (concat (regexp-opt howm-excluded-dirs t)
210 howm-excluded-file-regexp-dir-sep)))
211 (let ((howm-excluded-file-regexp-dots-ok
212 (mapconcat #'identity
213 `(,(concat dir-head excluded-dirs)
215 ,@howm-excluded-file-regexp-common-list)
217 (howm-excluded-file-regexp-dots-ng
218 (mapconcat #'identity
219 `(,(concat dir-head "\\([.]\\|" excluded-dirs "\\)")
220 ,@howm-excluded-file-regexp-common-list)
222 (howm-defcustom-risky howm-excluded-file-regexp
223 howm-excluded-file-regexp-dots-ng
224 "Regexp for excluded files.
225 It is checked for relative paths from howm-directory and howm-search-path.
226 A file is excluded iff this regexp matches with all the relative paths."
227 :type `(radio (const :tag "Don't search dot files"
228 ,howm-excluded-file-regexp-dots-ng)
229 (const :tag "Search dot files"
230 ,howm-excluded-file-regexp-dots-ok)
235 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
238 (defgroup howm-menu nil
242 (defcustom howm-menu-lang
243 (let ((lang-table '((fr "French" "^fr")
244 (ja "Japanese" "^ja"))))
245 (let ((lang (or (and (boundp 'current-language-environment)
246 current-language-environment)
248 (locale (howm-get-locale))
251 (if (or (string= lang (cadr rule))
252 (string-match (caddr rule) locale))
253 (setq ret (car rule))))
257 :type '(radio (const en) (const fr) (const ja))
260 (howm-defcustom-risky howm-menu-file nil
261 "*Specify menu file explicitly, or set as nil to search every time."
262 :type '(radio (const :tag "Search every time" nil)
263 (const "0000-00-00-000000.txt")
266 :group 'howm-efficiency
269 (defcustom howm-menu-expiry-hours 0
270 "*Cache menu contents for this number of hours."
272 :group 'howm-efficiency
275 (defcustom howm-menu-refresh-after-save t
276 "*If non-nil, refresh menu contents after you save howm note."
278 :group 'howm-efficiency
281 (defcustom howm-menu-name-format "*howmM:%s*"
282 "*Name format of menu buffer."
283 :type '(radio (const :tag "Never show in normal buffer list" " *howmM:%s*")
287 (defcustom howm-menu-footer nil
288 "Footer string for each menu. Nil means no footer."
289 :type '(radio (const :tag "Off" nil)
293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
296 (defgroup howm-reminder nil
297 "Schedule and todo list."
300 (defvar howm-reminder-old-format nil)
302 (defvar howm-reminder-marks
303 ;; Be careful to order of characters.
304 ;; "-" must be first so that regexp "[-+~!@.]" makes sense.
305 (if howm-reminder-old-format "-+~!@. " "-+~!@."))
306 (defvar howm-reminder-types
307 (format "[%s]" howm-reminder-marks))
309 (defun howm-custom-reminder-get-types (symbol)
310 (let ((reg (default-value symbol))
311 (default-types (split-string howm-reminder-marks "")))
312 ;; return list of types for standard cases
313 ;; and string itself for nonstandard cases
314 (if (not (string-match "^\\[\\(.*\\)\\]" reg))
316 (let ((types (split-string (match-string-no-properties 1 reg) "")))
317 (if (cl-find-if-not (lambda (x) (member x default-types))
320 (cl-remove-if-not (lambda (x) (member x types))
322 (defun howm-custom-reminder-set-types (symbol types)
324 (setq types (apply #'concat `("[" ,@types "]"))))
325 (set-default symbol types))
326 (defun howm-custom-reminder-list-types ()
327 `(radio (set ,@(mapcar (lambda (ty) (list 'const ty))
328 (split-string howm-reminder-marks "")))
331 (defcustom howm-schedule-types "[!@.]"
332 "*Regular expression of reminder types which are listed as schedule."
333 :get #'howm-custom-reminder-get-types
334 :set #'howm-custom-reminder-set-types
335 :type (howm-custom-reminder-list-types)
336 :group 'howm-efficiency
337 :group 'howm-reminder)
339 (defcustom howm-todo-types
340 (if howm-reminder-old-format "[-+~! .]" "[-+~!.]")
341 "*Regular expression of reminder types which are listed as todo."
342 :get #'howm-custom-reminder-get-types
343 :set #'howm-custom-reminder-set-types
344 :type (howm-custom-reminder-list-types)
345 :group 'howm-efficiency
346 :group 'howm-reminder)
348 (defcustom howm-congrats-format '("Finished %s tasks!")
349 "List of format strings to generate message when a reminder is finished.
350 One of elements is chosen randomly every time."
351 :type '(repeat string)
352 :group 'howm-reminder)
354 (howm-defcustom-risky howm-congrats-command nil
355 "*If non-nil, this command is executed when a reminder is finished.
356 Example: (\"play\" \"~/sound/fanfare.wav\") for calling the command
357 \"play ~/sound/fanfare.wav\"."
358 :type '(repeat string)
359 :group 'howm-reminder)
361 (defcustom howm-reminder-cancel-string "cancel"
362 "*This string is inserted automatically when a reminder is canceled."
364 :group 'howm-reminder)
366 (defcustom howm-action-lock-forward-save-buffer nil
367 "*Non nil if direct manipulation on reminder list should cause auto-save."
369 :group 'howm-reminder)
371 (defcustom howm-action-lock-forward-kill-buffer nil
372 "*Non nil if direct manipulation on reminder list should cause kill-buffer.
373 Be careful that you cannot undo the result of action-lock after kill-buffer."
375 :group 'howm-reminder)
378 (defcustom howm-action-lock-forward-fuzziness 5
379 "*Maximum lines of permitted inconsistency for `howm-action-lock-forward'."
381 :group 'howm-reminder))
383 (let* ((sep "- - - - - - - - - - - - - - - - - - -")
384 (reminder-default `((-1 . ,sep) (0 . ,sep) (nil . ,sep)))
385 (todo-default `((0 . ,sep) (nil . ,sep))))
386 (howm-if-ver1dot3 nil
387 (defcustom howm-menu-reminder-separators reminder-default
388 "Assoc list to specify positions and strings of separators in reminder
389 in menu. For each element, car is days from now, and cdr is separator string.
390 If car is nil, it means the border between schedule and todo.
391 This option is prepared for `howm-menu-reminder'."
392 :type `(radio (const :tag "No separators" nil)
393 (const :tag "Default separators" ,reminder-default)
396 (const :tag "Between schedule and todo" nil))
398 :group 'howm-reminder))
399 (defcustom howm-todo-separators nil
400 "Assoc list to specify positions and strings of separators in todo buffer.
401 For each element, car is priority and cdr is separator string.
402 If car is nil, it means the border between active and sleeping reminders."
403 :type `(radio (const :tag "No separators" nil)
404 (const :tag "Default separators" ,todo-default)
405 (alist :key-type number
407 :group 'howm-reminder))
409 (howm-if-ver1dot3 nil
410 (defcustom howm-schedule-sort-by-time t
411 "Non nil if `howm-schedule-sort-converter' should consider time part."
413 :group 'howm-reminder))
415 (defcustom howm-reminder-menu-types
416 (if howm-reminder-old-format "[-+~!@ ]" "[-+~!@]")
417 "*Regular expression of reminder types which are shown in menu."
418 :get #'howm-custom-reminder-get-types
419 :set #'howm-custom-reminder-set-types
420 :type (howm-custom-reminder-list-types)
421 :group 'howm-reminder)
427 (defgroup howm-menu-reminder nil
428 "Reminders shown in menu."
430 :group 'howm-reminder)
432 (defcustom howm-schedule-menu-types "[!@]"
433 "*Regular expression of reminder types which are shown in menu as schedule."
434 :get #'howm-custom-reminder-get-types
435 :set #'howm-custom-reminder-set-types
436 :type (howm-custom-reminder-list-types)
437 :group 'howm-efficiency
438 :group 'howm-menu-reminder)
440 (defcustom howm-todo-menu-types
441 (if howm-reminder-old-format "[-+~! .]" "[-+~!.]")
442 "*Regular expression of reminder types which are shown in menu as todo."
443 :get #'howm-custom-reminder-get-types
444 :set #'howm-custom-reminder-set-types
445 :type (howm-custom-reminder-list-types)
446 :group 'howm-efficiency
447 :group 'howm-menu-reminder)
449 (defcustom howm-menu-schedule-days 7
450 "*Show schedule in menu until this number of days from now."
452 :group 'howm-menu-reminder)
454 (defcustom howm-menu-schedule-days-before 0
455 "*Show schedule in menu from this number of days ago."
457 :group 'howm-menu-reminder)
459 (defcustom howm-menu-todo-num 50
460 "*Maximum number of todo items shown in menu."
462 :group 'howm-menu-reminder)
464 (defvar howm-huge- 66666)
465 (defvar howm-huge 77777)
466 (defvar howm-huge+ 88888)
467 (defvar howm-huge++ 99999)
469 (defcustom howm-menu-todo-priority (- howm-huge+)
470 "*Limit priority for elimination of reminders in menu."
471 :type `(radio (const :tag "Show sleeping reminders",(- howm-huge+))
472 (const :tag "Hide sleeping reminders" ,(- howm-huge-))
474 :group 'howm-menu-reminder)
476 (defcustom howm-todo-priority-done-bottom (- howm-huge+)
477 "*Base priority of done reminder.
478 <priority of done reminder> = <this value> + <days from specified date>"
479 :type `(radio (const :tag "Deeper than sleeping reminders" ,(- howm-huge+))
480 (const :tag "Shallower than sleeping reminders"
483 :group 'howm-menu-reminder)
485 (defcustom howm-menu-recent-num 20
486 "*Maximum number of recent items shown in menu."
488 :group 'howm-menu-reminder)
490 (defcustom howm-menu-recent-regexp nil
491 "Regexp which is regarded as title line in recent list in menu.
492 When it is nil, `howm-view-title-regexp' is used."
493 :type '(radio (const :tag "Default" nil)
496 :group 'howm-menu-reminder)
498 (defcustom howm-menu-todo-priority-format nil
499 "*Format for priority display in todo list in menu, or nil for no display."
500 :type '(radio (const :tag "Off" nil)
504 :group 'howm-menu-reminder)
506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
509 (defgroup howm-list nil
510 "Style of list view."
513 (defcustom howm-view-contents-limit nil
514 "*Max length for howm-view-contents. Nil means no limit."
515 :type '(radio (const :tag "No limit" nil)
519 (defcustom howm-view-summary-keep-cursor t
520 "*If non-nil, keep cursor position when you open a note from summary list."
524 (defcustom howm-view-summary-omit-same-name t
525 "*If non-nil, same name is not written repeatedly in summary list."
529 (defcustom howm-list-recent-days 7
530 "*This number of days are listed by `howm-list-recent'."
534 (defcustom howm-list-buffers-exclude
535 '("*Messages*" ".howm-keys" ".howm-history")
536 "*List of excluded buffer names for `howm-list-buffers'."
537 :type '(repeat string)
544 (defgroup howm-sort nil
545 "Sorting and filtering of matched entries."
548 (howm-defcustom-risky howm-list-normalizer nil
549 "*Obsolete. Use `howm-normalizer' insteadly."
550 :type '(radio (const :tag "Off (strongly recommended)" nil)
551 (function-item :tag "Sort by edit-time"
552 howm-view-sort-by-mtime)
553 (function-item :tag "Sort by create-time"
554 howm-view-sort-by-reverse-date)
558 (howm-defcustom-risky howm-normalizer 'howm-sort-items-by-mtime
559 "*Default method to list matched notes.
560 For backward compatibility, this value is overridden
561 if `howm-list-normalizer' is non-nil."
562 :type '(radio (function-item :tag "Sort by edit-time"
563 howm-sort-items-by-mtime)
564 (function-item :tag "Sort by create-time"
565 howm-sort-items-by-reverse-date)
569 (defcustom howm-list-prefer-word nil
570 "*Matches to whole word are listed first in summary buffer."
574 (defcustom howm-list-prefer-wiki t
575 "*Matches to wiki tags are listed first in summary buffer."
583 (defgroup howm-title nil
584 "Title of each entry."
587 ;; I don't know the way to generate this list automatically. Sigh...
588 (defvar howm-custom-command-list
589 `(set ,@(mapcar (lambda (com) (list 'const com))
598 howm-action-lock-date-search
601 (howm-defcustom-risky howm-list-title
606 ; howm-keyword-search
607 ; howm-list-grep howm-list-grep-fixed howm-list-migemo
609 howm-action-lock-date-search
611 "List of commands in which titles are listed instead of matched lines.
613 If it is a function, the evaluated value is used instead of itself."
614 :type `(radio (const :tag "Always" t)
615 (const :tag "Never" nil)
616 ,howm-custom-command-list
617 ;; (set (const howm-list-all)
618 ;; (const howm-list-recent)
619 ;; (const howm-list-around)
620 ;; (const howm-keyword-search)
621 ;; (const howm-list-grep)
622 ;; (const howm-list-grep-fixed)
623 ;; (const howm-list-migemo)
624 ;; (const howm-list-related))
626 :group 'howm-efficiency
629 (defcustom howm-list-title-regexp nil
630 "Regexp which is regarded as title line in summary buffer.
631 When it is nil, `howm-view-title-regexp' is used."
632 :type '(radio (const :tag "Default" nil)
636 (defcustom howm-list-title-undo t
637 "*Non-nil if `howm-list-toggle-title' should toggle whether title is shown
640 :group 'howm-efficiency
647 (defgroup howm-list-bufwin nil
648 "Buffers and windows for listing search result."
651 (defcustom howm-view-summary-name "*howmS*"
652 "Format string of buffer name for summary.
653 %s is replaced with searched string. See `format'."
654 :type '(radio (const :tag "Use one common buffer" "*howmS*")
655 (const :tag "Make new buffer for each search" "*howmS:%s*")
657 :group 'howm-list-bufwin)
659 (defcustom howm-view-contents-name "*howmC*"
660 "Format string of buffer name for contents.
661 %s is replaced with searched string. See `format'."
662 :type '(radio (const :tag "Use one common buffer" "*howmC*")
663 (const :tag "Make new buffer for each search" "*howmC:%s*")
665 :group 'howm-list-bufwin)
667 (howm-defcustom-risky howm-view-summary-persistent t
668 "*If non-nil, keep summary buffer on howm-view-summary-open by default.
669 If it is a function, the evaluated value is used instead of itself."
671 :group 'howm-list-bufwin)
673 (howm-defcustom-risky howm-view-contents-persistent t
674 "*If non-nil, keep contents buffer on howm-view-contents-open by default.
675 If it is a function, the evaluated value is used instead of itself."
677 :group 'howm-list-bufwin)
679 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
682 (defgroup howm-search nil
686 (defcustom howm-keyword-case-fold-search nil
687 "*Non-nil if searches of come-from keywords should ignore case."
691 (defcustom howm-check-word-break nil
692 "*Non-nil if come-from keywords within a word should not linked.
693 When the value is a string (regexp), word breaks are checked
694 only for matched keywords. "
695 :type '(radio (const :tag "Always" t)
696 (const :tag "Never" nil)
697 (const :tag "ASCII only" "^[[:ascii:]]+$")
701 (defcustom howm-view-update-search-ring nil
702 "*Non-nil if search-ring should be updated in howm search."
706 (defcustom howm-message-time nil
707 "*Non nil if search etc. should show took time."
712 (howm-defcustom-risky howm-history-file "~/.howm-history"
713 "*Search history is recorded to that file."
718 (defcustom howm-history-limit 50
719 "*Limit number of recorded search history, or nil for no limit.
720 Set 0 to inhibit recording."
721 :type '(radio (const :tag "No limit" nil)
725 (defcustom howm-history-unique t
726 "*If non-nil, duplicated entries are removed from search history."
730 (defcustom howm-keyword-list-alias-sep "\t"
731 "*Separator string for alias keywords in the keyword file `howm-keyword-file'.
732 If it is nil, alias of come-from keyword is disabled."
733 :type '(radio (const :tag "Disable aliases" nil)
734 (const :tag "Tab" "\t")
738 (defcustom howm-keyword-aliases-recursive t
739 "*Non nil if aliases of come-from keywords should be expanded recursively."
747 (defgroup howm-grep nil
748 "Use external grep command for fast search."
749 :group 'howm-efficiency
752 (howm-defcustom-risky howm-view-use-grep nil
753 "*If non-nil, use external grep command for search.
754 Performance must be improved greatly if you set this.
755 When the value is elisp function, it is used instead of `howm-fake-grep'."
756 :type '(radio (const :tag "On" t)
757 (const :tag "Off" nil)
761 ;; These variables should be renamed: howm-view-xxx ==> howm-xxx.
762 (howm-defcustom-risky howm-view-grep-command "grep"
763 "*Command name for grep."
766 (howm-defvar-risky howm-view-fgrep-command nil
767 "*Command name for fgrep.
768 This variable is obsolete and may be removed in future.")
769 (defvar howm-view-grep-default-option
770 ;; "labels" causes a trouble in git-head emacs (d5e3922) [2015-01-31]
771 (let* ((ed (lambda (d) (concat "--exclude-dir=" d)))
772 (has-ed (condition-case nil
773 (eq 0 (call-process howm-view-grep-command nil nil nil
774 (apply ed "/") "--version"))
776 (opts (cons "-Hnr" (and has-ed (mapcar ed howm-excluded-dirs)))))
777 (mapconcat #'identity opts " ")))
778 (howm-defcustom-risky howm-view-grep-option howm-view-grep-default-option
779 "*Common grep option for howm."
780 :type `(radio (const :tag "scan all files"
781 ,howm-view-grep-default-option)
782 (const :tag "scan *.howm only"
783 ,(concat howm-view-grep-default-option
784 " --include=*.howm"))
787 (howm-defcustom-risky howm-view-grep-extended-option "-E"
788 "*Grep option for extended regular expression."
791 (howm-defcustom-risky howm-view-grep-fixed-option "-F"
792 "*Grep option to search fixed strings."
795 (howm-defcustom-risky howm-view-grep-ignore-case-option "-i"
796 "*Grep option for ignoring case distinctions."
799 (howm-defcustom-risky howm-view-grep-expr-option "-e"
800 "*Grep option for pattern."
803 (howm-defcustom-risky howm-view-grep-file-stdin-option "-f -"
804 "*Grep option for receiving patterns from standard input.
805 If this is nil, pattern is received as command line argument."
806 :type '(radio (const :tag "Off" nil)
810 (howm-defcustom-risky howm-command-length-limit 10000
811 "*Maximum length of command line for call-process."
815 (defcustom howm-process-coding-system nil
816 "*Default coding system for grep command in howm.
817 If the value is a symbol, it is used for both read and write.
818 If the value is a cons pair, its car and cdr are used for read and write,
822 (setq howm-process-coding-system 'euc-japan-unix)
823 (setq howm-process-coding-system '(utf-8-unix . sjis-unix))"
824 :type '(radio (const :tag "Off" nil)
826 (cons coding-system coding-system))
829 (howm-if-ver1dot3 nil
830 (defcustom howm-occur-force-fake-grep t
831 "*If non-nil, force `howm-occur' to use `howm-fake-grep'
832 so that highlighting works correctly."
836 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
839 (defgroup howm-misc nil
840 "Miscellaneous customization."
843 (defvar howm-prefix "\C-c,"
844 "Howm commands are invoked by this prefix + some keys.")
846 (defcustom howm-random-walk-wait 2
847 "*Seconds of wait in `howm-random-walk'."
851 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
854 (defgroup howm-create nil
858 (defcustom howm-prepend nil
859 "*Non nil if new entries should be prepended to previous entries.
860 Otherwise, they are appended."
861 :type '(radio (const :tag "Append" nil)
862 (const :tag "Prepend" t))
865 (defcustom howm-content-from-region nil
866 "*When the value non-nil, selected string is inserted as default content.
867 Unless the value is t, single-line selection is inserted as title instead.
868 This variable is ignored when `transient-mark-mode' is nil."
869 :type '(radio (const :tag "Off" nil)
870 (const :tag "Single line selection is copied as title" 1)
871 (const :tag "Any selection is copied as content" t))
874 (defcustom howm-title-from-search nil
875 "*Non nil if searched keyword is inserted as default title
876 when `howm-create' is called on summary buffer."
880 (defcustom howm-create-here-just nil
881 "*Non nil if `howm-create-here' should insert new entry into cursor position
882 rather than append or prepend."
883 :type '(radio (const :tag "Append or prepend" nil)
884 (const :tag "Just here" t))
887 (defcustom howm-remember-first-line-to-title nil
888 "If non-nil, the first line in `howm-remember' is set to %title
889 and the rest lines are inserted to the position at %cursor in `howm-template.
890 If nil, all the lines are simply inserted at %cursor."
894 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
897 (defgroup howm-viewer nil
898 "External viewers for images, movies, sounds, etc."
901 (defun howm-try-require (feature)
902 (and (locate-library (symbol-name feature))
905 ;; These variables should be renamed.
907 (howm-defcustom-risky howm-view-external-viewer-assoc nil
908 "List of viewer specifications.
909 Each specification must be a cons pair of type and format.
910 Type is a regular expression of file names.
911 Format is a command string in which %s is replaced with file name.
912 This setting is prior to mailcap.
914 This variable is marked as a risky local variable
915 because `howm-viewer-dispatchers' `howm-viewer-indicator'
916 and `howm-viewer-type' accept functions instead of format strings.
919 (setq howm-view-external-viewer-assoc
921 (\"[.]\\(jpg\\|gif\\|png\\)$\" . \"display %s\")
922 (\"[.]dvi$\" . \"xdvi %s\")
925 :type '(alist :key-type regexp :value-type string)
928 (defcustom howm-view-use-mailcap
929 (and (howm-try-require 'mailcap)
930 (fboundp 'mailcap-parse-mailcaps)
931 (fboundp 'mailcap-parse-mimetypes))
932 "*Non nil if external viewers should be selected according to mailcap.
933 Mailcap processing depends on gnus/mailcap, and old FLIM library may
938 (defcustom howm-view-open-by-myself '("text/.*" "application/emacs-lisp")
939 "List of regular expressions for mime types which should be opened normally."
940 :type '(repeat regexp)
943 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
946 (defgroup howm-narrow nil
947 "Narrowing to each entry."
950 (defcustom howm-auto-narrow t
951 "List of commands after which the function `howm-auto-narrow' can work.
952 If the value is t, it means 'always'."
953 :type `(radio (const :tag "Never" nil)
954 (const :tag "Always" t)
955 ,howm-custom-command-list)
958 (mapc (lambda (hook) (custom-add-option hook 'howm-auto-narrow))
959 '(howm-view-open-hook howm-create-hook))
961 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
964 (defgroup howm-efficiency nil
965 "To improve performance, use grep and turn off expensive options."
968 (defcustom howm-refresh-after-save t
969 "*Redraw links after you save howm note."
971 :group 'howm-efficiency)
973 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
976 (defgroup howm-faces nil
981 (howm-defcustom-risky howm-user-font-lock-keywords nil
982 "Font lock keywords for all howm-related buffers.
983 See help of `font-lock-keywords' for details.
984 Note: `howm-menu-font-lock-rules' overrides this variable."
985 ;; :type '(repeat (radio (cons regexp (list (const quote) face))
990 (defcustom howm-use-color t
991 "*If non-nil, highlight tags in howm-mode verbosely."
995 (defface howm-view-hilit-face
996 '((((class color)) (:foreground "red"))
998 "*Face for matched word."
1001 (defface howm-view-name-face
1002 '((((class color)) (:foreground "white" :background "blue"))
1004 "*Face for file name in summary buffer."
1007 (defface howm-view-empty-face
1008 '((((class color)) (:background "midnight blue"))
1010 "*Face for empty field in summary buffer."
1013 (defface howm-mode-title-face ;; =
1014 '((((class color)) (:foreground "RoyalBlue"))
1018 (defface howm-mode-ref-face ;; >>>
1019 '((((class color) (background light)) (:foreground "blue"))
1020 (((class color) (background dark)) (:foreground "cyan"))
1022 "*Face for goto link."
1024 (defface howm-mode-keyword-face ;; <<<
1025 '((((class color)) (:foreground "white" :background "blue"))
1027 "*Face for come-from link."
1029 (defface howm-mode-wiki-face ;; [[]]
1030 '((((class color) (background light)) (:foreground "blue"))
1031 (((class color) (background dark)) (:foreground "cyan"))
1033 "*Face for wiki link."
1036 (defface howm-reminder-normal-face
1037 '((((class color)) (:foreground "blue"))
1039 "*Face for normal reminder."
1041 (defface howm-reminder-todo-face
1042 '((((class color) (background light)) (:foreground "purple"))
1043 (((class color) (background dark)) (:foreground "yellow"))
1047 (defface howm-reminder-defer-face
1048 '((((class color)) (:foreground "magenta"))
1052 (defface howm-reminder-deadline-face
1053 '((((class color)) (:foreground "red"))
1055 "*Face for deadline."
1057 (defface howm-reminder-late-deadline-face
1058 '((((class color)) (:background "red" :foreground "black"))
1060 "*Face for late deadline."
1062 (defface howm-reminder-schedule-face
1063 '((((class color) (background light)) (:foreground "dark green"))
1064 (((class color) (background dark)) (:foreground "green"))
1066 "*Face for schedule."
1068 (defface howm-reminder-done-face
1069 '((((class color) (background light)) ())
1070 (((class color) (background dark)) (:foreground "gray"))
1072 "*Face for done reminder."
1074 (defface howm-reminder-today-face
1075 '((((class color)) (:foreground "black" :background "orange"))
1079 (defface howm-reminder-tomorrow-face
1080 '((((class color)) (:foreground "black" :background "pink"))
1082 "*Face for tommorow."
1085 (defface howm-menu-list-face ;; item header in menu-mode list (schedule, todo)
1087 "*Face for list in menu."
1089 (defface howm-menu-key-face ;; shortcut key in menu-mode
1090 '((((class color) (background light)) (:foreground "dark red"))
1091 (((class color) (background dark)) (:foreground "orange"))
1093 "*Face for key binding in menu."
1096 (defvar howm-view-hilit-face 'howm-view-hilit-face
1097 "*Face for matched word.")
1098 (defvar howm-view-name-face 'howm-view-name-face
1099 "*Face for file name in summary buffer.")
1100 (defvar howm-view-empty-face 'howm-view-empty-face
1101 "*Face for empty field in summary buffer.")
1102 (defvar howm-mode-title-face 'howm-mode-title-face
1104 (defvar howm-mode-ref-face 'howm-mode-ref-face
1105 "*Face for goto link.")
1106 (defvar howm-mode-keyword-face 'howm-mode-keyword-face
1107 "*Face for come-from link.")
1108 (defvar howm-mode-wiki-face 'howm-mode-wiki-face
1109 "*Face for wiki link.")
1110 (defvar howm-reminder-normal-face 'howm-reminder-normal-face
1111 "*Face for normal reminder.")
1112 (defvar howm-reminder-todo-face 'howm-reminder-todo-face
1114 (defvar howm-reminder-defer-face 'howm-reminder-defer-face
1116 (defvar howm-reminder-deadline-face 'howm-reminder-deadline-face
1117 "*Face for deadline.")
1118 (defvar howm-reminder-late-deadline-face 'howm-reminder-late-deadline-face
1119 "*Face for late deadline.")
1120 (defvar howm-reminder-schedule-face 'howm-reminder-schedule-face
1121 "*Face for schedule.")
1122 (defvar howm-reminder-done-face 'howm-reminder-done-face
1123 "*Face for done reminder.")
1124 (defvar howm-reminder-today-face 'howm-reminder-today-face
1126 (defvar howm-reminder-tomorrow-face 'howm-reminder-tomorrow-face
1127 "*Face for tommorow.")
1128 (defvar howm-menu-list-face 'howm-menu-list-face
1129 "*Face for list in menu.")
1130 (defvar howm-menu-key-face 'howm-menu-key-face
1131 "*Face for key binding in menu.")
1133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1136 (defgroup howm-hooks nil
1140 (defcustom howm-mode-hook nil
1141 "Hook run at the end of function `howm-mode'"
1145 (defcustom howm-mode-on-hook nil
1146 "Hook run when `howm-mode' is turned on."
1150 (defcustom howm-mode-off-hook nil
1151 "Hook run when `howm-mode' is turned off."
1155 (defcustom howm-view-open-hook nil
1156 "Hook run when open a note from summary/contents buffer."
1161 (defcustom howm-view-before-open-hook nil
1162 "Hook run before open something from summary or contents buffer."
1166 (defcustom howm-create-file-hook nil
1167 "Hook run when buffer for new note is created."
1171 (defcustom howm-create-hook nil
1172 "Hook run after new note is created and set up."
1177 (defcustom howm-menu-hook nil
1178 "Hook run at the end of `howm-menu-refresh'."
1182 (defcustom howm-congrats-hook nil
1183 "Hook run at the end of `howm-congrats'."
1187 (defcustom howm-after-save-hook nil
1188 "Hook run at the end of `howm-after-save'."
1192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1195 (defgroup howm-devel nil
1196 "Developers' diagnoses."
1199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1202 (defgroup howm-experimental nil
1203 "Test of experimental features."
1206 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1207 ;; Date format (need refactoring)
1209 (defvar howm-date-separator "-") ;; "-" ==> 2003-10-21
1211 ;; Fix me: redundant (howm-date-* & howm-reminder-*)
1212 ;; (cf.) howm-reminder-regexp-grep-* howm-reminder-today-format
1213 (defvar howm-date-regexp-grep
1214 (concat "[1-2][0-9][0-9][0-9]" howm-date-separator
1215 "[0-1][0-9]" howm-date-separator
1217 (defvar howm-date-regexp
1218 (concat "\\([1-2][0-9][0-9][0-9]\\)" howm-date-separator
1219 "\\([0-1][0-9]\\)" howm-date-separator
1220 "\\([0-3][0-9]\\)"))
1221 (defvar howm-date-regexp-year-pos 1)
1222 (defvar howm-date-regexp-month-pos 2)
1223 (defvar howm-date-regexp-day-pos 3)
1224 (defvar howm-date-format
1225 (concat "%Y" howm-date-separator "%m" howm-date-separator "%d"))
1226 (defvar howm-dtime-body-format
1227 (concat howm-date-format " %H:%M"))
1228 (defvar howm-dtime-format
1229 (concat "[" howm-dtime-body-format "]"))
1230 (defvar howm-insert-date-format "[%s]")
1231 (defvar howm-insert-date-future nil)
1233 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1234 ;; Avoid reference to free variable (need refactoring)
1236 (howm-defvar-risky howm-menu-action-arg 'howm-menu-action-arg-name)
1240 (provide 'howm-vars)
1242 ;;; howm-vars.el ends here