1 ;;; howm-vars.el --- Wiki-like note-taking tool
2 ;;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016
3 ;;; HIRAOKA Kazuyuki <khi@users.sourceforge.jp>
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 (if (or (and (boundp 'current-language-environment)
244 (string= current-language-environment "Japanese"))
245 (string-match "^ja" (howm-get-locale)))
249 :type '(radio (const en) (const ja))
252 (howm-defcustom-risky howm-menu-file nil
253 "*Specify menu file explicitly, or set as nil to search every time."
254 :type '(radio (const :tag "Search every time" nil)
255 (const "0000-00-00-000000.txt")
258 :group 'howm-efficiency
261 (defcustom howm-menu-expiry-hours 0
262 "*Cache menu contents for this number of hours."
264 :group 'howm-efficiency
267 (defcustom howm-menu-refresh-after-save t
268 "*If non-nil, refresh menu contents after you save howm note."
270 :group 'howm-efficiency
273 (defcustom howm-menu-name-format "*howmM:%s*"
274 "*Name format of menu buffer."
275 :type '(radio (const :tag "Never show in normal buffer list" " *howmM:%s*")
279 (defcustom howm-menu-footer nil
280 "Footer string for each menu. Nil means no footer."
281 :type '(radio (const :tag "Off" nil)
285 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
288 (defgroup howm-reminder nil
289 "Schedule and todo list."
292 (defvar howm-reminder-old-format nil)
294 (defvar howm-reminder-marks
295 ;; Be careful to order of characters.
296 ;; "-" must be first so that regexp "[-+~!@.]" makes sense.
297 (if howm-reminder-old-format "-+~!@. " "-+~!@."))
298 (defvar howm-reminder-types
299 (format "[%s]" howm-reminder-marks))
301 (defun howm-custom-reminder-get-types (symbol)
302 (let ((reg (default-value symbol))
303 (default-types (split-string howm-reminder-marks "")))
304 ;; return list of types for standard cases
305 ;; and string itself for nonstandard cases
306 (if (not (string-match "^\\[\\(.*\\)\\]" reg))
308 (let ((types (split-string (match-string-no-properties 1 reg) "")))
309 (if (cl-find-if-not (lambda (x) (member x default-types))
312 (cl-remove-if-not (lambda (x) (member x types))
314 (defun howm-custom-reminder-set-types (symbol types)
316 (setq types (apply #'concat `("[" ,@types "]"))))
317 (set-default symbol types))
318 (defun howm-custom-reminder-list-types ()
319 `(radio (set ,@(mapcar (lambda (ty) (list 'const ty))
320 (split-string howm-reminder-marks "")))
323 (defcustom howm-schedule-types "[!@.]"
324 "*Regular expression of reminder types which are listed as schedule."
325 :get #'howm-custom-reminder-get-types
326 :set #'howm-custom-reminder-set-types
327 :type (howm-custom-reminder-list-types)
328 :group 'howm-efficiency
329 :group 'howm-reminder)
331 (defcustom howm-todo-types
332 (if howm-reminder-old-format "[-+~! .]" "[-+~!.]")
333 "*Regular expression of reminder types which are listed as todo."
334 :get #'howm-custom-reminder-get-types
335 :set #'howm-custom-reminder-set-types
336 :type (howm-custom-reminder-list-types)
337 :group 'howm-efficiency
338 :group 'howm-reminder)
340 (defcustom howm-congrats-format '("Finished %s tasks!")
341 "List of format strings to generate message when a reminder is finished.
342 One of elements is chosen randomly every time."
343 :type '(repeat string)
344 :group 'howm-reminder)
346 (howm-defcustom-risky howm-congrats-command nil
347 "*If non-nil, this command is executed when a reminder is finished.
348 Example: (\"play\" \"~/sound/fanfare.wav\") for calling the command
349 \"play ~/sound/fanfare.wav\"."
350 :type '(repeat string)
351 :group 'howm-reminder)
353 (defcustom howm-reminder-cancel-string "cancel"
354 "*This string is inserted automatically when a reminder is canceled."
356 :group 'howm-reminder)
358 (defcustom howm-action-lock-forward-save-buffer nil
359 "*Non nil if direct manipulation on reminder list should cause auto-save."
361 :group 'howm-reminder)
363 (defcustom howm-action-lock-forward-kill-buffer nil
364 "*Non nil if direct manipulation on reminder list should cause kill-buffer.
365 Be careful that you cannot undo the result of action-lock after kill-buffer."
367 :group 'howm-reminder)
370 (defcustom howm-action-lock-forward-fuzziness 5
371 "*Maximum lines of permitted inconsistency for `howm-action-lock-forward'."
373 :group 'howm-reminder))
375 (let* ((sep "- - - - - - - - - - - - - - - - - - -")
376 (reminder-default `((-1 . ,sep) (0 . ,sep) (nil . ,sep)))
377 (todo-default `((0 . ,sep) (nil . ,sep))))
378 (howm-if-ver1dot3 nil
379 (defcustom howm-menu-reminder-separators reminder-default
380 "Assoc list to specify positions and strings of separators in reminder
381 in menu. For each element, car is days from now, and cdr is separator string.
382 If car is nil, it means the border between schedule and todo.
383 This option is prepared for `howm-menu-reminder'."
384 :type `(radio (const :tag "No separators" nil)
385 (const :tag "Default separators" ,reminder-default)
388 (const :tag "Between schedule and todo" nil))
390 :group 'howm-reminder))
391 (defcustom howm-todo-separators nil
392 "Assoc list to specify positions and strings of separators in todo buffer.
393 For each element, car is priority and cdr is separator string.
394 If car is nil, it means the border between active and sleeping reminders."
395 :type `(radio (const :tag "No separators" nil)
396 (const :tag "Default separators" ,todo-default)
397 (alist :key-type number
399 :group 'howm-reminder))
401 (howm-if-ver1dot3 nil
402 (defcustom howm-schedule-sort-by-time t
403 "Non nil if `howm-schedule-sort-converter' should consider time part."
405 :group 'howm-reminder))
407 (defcustom howm-reminder-menu-types
408 (if howm-reminder-old-format "[-+~!@ ]" "[-+~!@]")
409 "*Regular expression of reminder types which are shown in menu."
410 :get #'howm-custom-reminder-get-types
411 :set #'howm-custom-reminder-set-types
412 :type (howm-custom-reminder-list-types)
413 :group 'howm-reminder)
419 (defgroup howm-menu-reminder nil
420 "Reminders shown in menu."
422 :group 'howm-reminder)
424 (defcustom howm-schedule-menu-types "[!@]"
425 "*Regular expression of reminder types which are shown in menu as schedule."
426 :get #'howm-custom-reminder-get-types
427 :set #'howm-custom-reminder-set-types
428 :type (howm-custom-reminder-list-types)
429 :group 'howm-efficiency
430 :group 'howm-menu-reminder)
432 (defcustom howm-todo-menu-types
433 (if howm-reminder-old-format "[-+~! .]" "[-+~!.]")
434 "*Regular expression of reminder types which are shown in menu as todo."
435 :get #'howm-custom-reminder-get-types
436 :set #'howm-custom-reminder-set-types
437 :type (howm-custom-reminder-list-types)
438 :group 'howm-efficiency
439 :group 'howm-menu-reminder)
441 (defcustom howm-menu-schedule-days 7
442 "*Show schedule in menu until this number of days from now."
444 :group 'howm-menu-reminder)
446 (defcustom howm-menu-schedule-days-before 0
447 "*Show schedule in menu from this number of days ago."
449 :group 'howm-menu-reminder)
451 (defcustom howm-menu-todo-num 50
452 "*Maximum number of todo items shown in menu."
454 :group 'howm-menu-reminder)
456 (defvar howm-huge- 66666)
457 (defvar howm-huge 77777)
458 (defvar howm-huge+ 88888)
459 (defvar howm-huge++ 99999)
461 (defcustom howm-menu-todo-priority (- howm-huge+)
462 "*Limit priority for elimination of reminders in menu."
463 :type `(radio (const :tag "Show sleeping reminders",(- howm-huge+))
464 (const :tag "Hide sleeping reminders" ,(- howm-huge-))
466 :group 'howm-menu-reminder)
468 (defcustom howm-todo-priority-done-bottom (- howm-huge+)
469 "*Base priority of done reminder.
470 <priority of done reminder> = <this value> + <days from specified date>"
471 :type `(radio (const :tag "Deeper than sleeping reminders" ,(- howm-huge+))
472 (const :tag "Shallower than sleeping reminders"
475 :group 'howm-menu-reminder)
477 (defcustom howm-menu-recent-num 20
478 "*Maximum number of recent items shown in menu."
480 :group 'howm-menu-reminder)
482 (defcustom howm-menu-recent-regexp nil
483 "Regexp which is regarded as title line in recent list in menu.
484 When it is nil, `howm-view-title-regexp' is used."
485 :type '(radio (const :tag "Default" nil)
488 :group 'howm-menu-reminder)
490 (defcustom howm-menu-todo-priority-format nil
491 "*Format for priority display in todo list in menu, or nil for no display."
492 :type '(radio (const :tag "Off" nil)
496 :group 'howm-menu-reminder)
498 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
501 (defgroup howm-list nil
502 "Style of list view."
505 (defcustom howm-view-contents-limit nil
506 "*Max length for howm-view-contents. Nil means no limit."
507 :type '(radio (const :tag "No limit" nil)
511 (defcustom howm-view-summary-keep-cursor t
512 "*If non-nil, keep cursor position when you open a note from summary list."
516 (defcustom howm-view-summary-omit-same-name t
517 "*If non-nil, same name is not written repeatedly in summary list."
521 (defcustom howm-list-recent-days 7
522 "*This number of days are listed by `howm-list-recent'."
526 (defcustom howm-list-buffers-exclude
527 '("*Messages*" ".howm-keys" ".howm-history")
528 "*List of excluded buffer names for `howm-list-buffers'."
529 :type '(repeat string)
536 (defgroup howm-sort nil
537 "Sorting and filtering of matched entries."
540 (howm-defcustom-risky howm-list-normalizer nil
541 "*Obsolete. Use `howm-normalizer' insteadly."
542 :type '(radio (const :tag "Off (strongly recommended)" nil)
543 (function-item :tag "Sort by edit-time"
544 howm-view-sort-by-mtime)
545 (function-item :tag "Sort by create-time"
546 howm-view-sort-by-reverse-date)
550 (howm-defcustom-risky howm-normalizer 'howm-sort-items-by-mtime
551 "*Default method to list matched notes.
552 For backward compatibility, this value is overridden
553 if `howm-list-normalizer' is non-nil."
554 :type '(radio (function-item :tag "Sort by edit-time"
555 howm-sort-items-by-mtime)
556 (function-item :tag "Sort by create-time"
557 howm-sort-items-by-reverse-date)
561 (defcustom howm-list-prefer-word nil
562 "*Matches to whole word are listed first in summary buffer."
566 (defcustom howm-list-prefer-wiki t
567 "*Matches to wiki tags are listed first in summary buffer."
575 (defgroup howm-title nil
576 "Title of each entry."
579 ;; I don't know the way to generate this list automatically. Sigh...
580 (defvar howm-custom-command-list
581 `(set ,@(mapcar (lambda (com) (list 'const com))
590 howm-action-lock-date-search
593 (howm-defcustom-risky howm-list-title
598 ; howm-keyword-search
599 ; howm-list-grep howm-list-grep-fixed howm-list-migemo
601 howm-action-lock-date-search
603 "List of commands in which titles are listed instead of matched lines.
605 If it is a function, the evaluated value is used instead of itself."
606 :type `(radio (const :tag "Always" t)
607 (const :tag "Never" nil)
608 ,howm-custom-command-list
609 ;; (set (const howm-list-all)
610 ;; (const howm-list-recent)
611 ;; (const howm-list-around)
612 ;; (const howm-keyword-search)
613 ;; (const howm-list-grep)
614 ;; (const howm-list-grep-fixed)
615 ;; (const howm-list-migemo)
616 ;; (const howm-list-related))
618 :group 'howm-efficiency
621 (defcustom howm-list-title-regexp nil
622 "Regexp which is regarded as title line in summary buffer.
623 When it is nil, `howm-view-title-regexp' is used."
624 :type '(radio (const :tag "Default" nil)
628 (defcustom howm-list-title-undo t
629 "*Non-nil if `howm-list-toggle-title' should toggle whether title is shown
632 :group 'howm-efficiency
639 (defgroup howm-list-bufwin nil
640 "Buffers and windows for listing search result."
643 (defcustom howm-view-summary-name "*howmS*"
644 "Format string of buffer name for summary.
645 %s is replaced with searched string. See `format'."
646 :type '(radio (const :tag "Use one common buffer" "*howmS*")
647 (const :tag "Make new buffer for each search" "*howmS:%s*")
649 :group 'howm-list-bufwin)
651 (defcustom howm-view-contents-name "*howmC*"
652 "Format string of buffer name for contents.
653 %s is replaced with searched string. See `format'."
654 :type '(radio (const :tag "Use one common buffer" "*howmC*")
655 (const :tag "Make new buffer for each search" "*howmC:%s*")
657 :group 'howm-list-bufwin)
659 (howm-defcustom-risky howm-view-summary-persistent t
660 "*If non-nil, keep summary buffer on howm-view-summary-open by default.
661 If it is a function, the evaluated value is used instead of itself."
663 :group 'howm-list-bufwin)
665 (howm-defcustom-risky howm-view-contents-persistent t
666 "*If non-nil, keep contents buffer on howm-view-contents-open by default.
667 If it is a function, the evaluated value is used instead of itself."
669 :group 'howm-list-bufwin)
671 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
674 (defgroup howm-search nil
678 (defcustom howm-keyword-case-fold-search nil
679 "*Non-nil if searches of come-from keywords should ignore case."
683 (defcustom howm-check-word-break nil
684 "*Non-nil if come-from keywords within a word should not linked.
685 When the value is a string (regexp), word breaks are checked
686 only for matched keywords. "
687 :type '(radio (const :tag "Always" t)
688 (const :tag "Never" nil)
689 (const :tag "ASCII only" "^[[:ascii:]]+$")
693 (defcustom howm-view-update-search-ring nil
694 "*Non-nil if search-ring should be updated in howm search."
698 (defcustom howm-message-time nil
699 "*Non nil if search etc. should show took time."
704 (howm-defcustom-risky howm-history-file "~/.howm-history"
705 "*Search history is recorded to that file."
710 (defcustom howm-history-limit 50
711 "*Limit number of recorded search history, or nil for no limit.
712 Set 0 to inhibit recording."
713 :type '(radio (const :tag "No limit" nil)
717 (defcustom howm-history-unique t
718 "*If non-nil, duplicated entries are removed from search history."
722 (defcustom howm-keyword-list-alias-sep "\t"
723 "*Separator string for alias keywords in the keyword file `howm-keyword-file'.
724 If it is nil, alias of come-from keyword is disabled."
725 :type '(radio (const :tag "Disable aliases" nil)
726 (const :tag "Tab" "\t")
730 (defcustom howm-keyword-aliases-recursive t
731 "*Non nil if aliases of come-from keywords should be expanded recursively."
739 (defgroup howm-grep nil
740 "Use external grep command for fast search."
741 :group 'howm-efficiency
744 (howm-defcustom-risky howm-view-use-grep nil
745 "*If non-nil, use external grep command for search.
746 Performance must be improved greatly if you set this.
747 When the value is elisp function, it is used instead of `howm-fake-grep'."
748 :type '(radio (const :tag "On" t)
749 (const :tag "Off" nil)
753 ;; These variables should be renamed: howm-view-xxx ==> howm-xxx.
754 (howm-defcustom-risky howm-view-grep-command "grep"
755 "*Command name for grep."
758 (howm-defvar-risky howm-view-fgrep-command nil
759 "*Command name for fgrep.
760 This variable is obsolete and may be removed in future.")
761 (defvar howm-view-grep-default-option
762 ;; "labels" causes a trouble in git-head emacs (d5e3922) [2015-01-31]
763 (let* ((ed (lambda (d) (concat "--exclude-dir=" d)))
764 (has-ed (condition-case nil
765 (eq 0 (call-process howm-view-grep-command nil nil nil
766 (apply ed "/") "--version"))
768 (opts (cons "-Hnr" (and has-ed (mapcar ed howm-excluded-dirs)))))
769 (mapconcat #'identity opts " ")))
770 (howm-defcustom-risky howm-view-grep-option howm-view-grep-default-option
771 "*Common grep option for howm."
772 :type `(radio (const :tag "scan all files"
773 ,howm-view-grep-default-option)
774 (const :tag "scan *.howm only"
775 ,(concat howm-view-grep-default-option
776 " --include=*.howm"))
779 (howm-defcustom-risky howm-view-grep-extended-option "-E"
780 "*Grep option for extended regular expression."
783 (howm-defcustom-risky howm-view-grep-fixed-option "-F"
784 "*Grep option to search fixed strings."
787 (howm-defcustom-risky howm-view-grep-ignore-case-option "-i"
788 "*Grep option for ignoring case distinctions."
791 (howm-defcustom-risky howm-view-grep-expr-option "-e"
792 "*Grep option for pattern."
795 (howm-defcustom-risky howm-view-grep-file-stdin-option "-f -"
796 "*Grep option for receiving patterns from standard input.
797 If this is nil, pattern is received as command line argument."
798 :type '(radio (const :tag "Off" nil)
802 (howm-defcustom-risky howm-command-length-limit 10000
803 "*Maximum length of command line for call-process."
807 (defcustom howm-process-coding-system nil
808 "*Default coding system for grep command in howm.
809 If the value is a symbol, it is used for both read and write.
810 If the value is a cons pair, its car and cdr are used for read and write,
814 (setq howm-process-coding-system 'euc-japan-unix)
815 (setq howm-process-coding-system '(utf-8-unix . sjis-unix))"
816 :type '(radio (const :tag "Off" nil)
818 (cons coding-system coding-system))
821 (howm-if-ver1dot3 nil
822 (defcustom howm-occur-force-fake-grep t
823 "*If non-nil, force `howm-occur' to use `howm-fake-grep'
824 so that highlighting works correctly."
828 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
831 (defgroup howm-misc nil
832 "Miscellaneous customization."
835 (defvar howm-prefix "\C-c,"
836 "Howm commands are invoked by this prefix + some keys.")
838 (defcustom howm-random-walk-wait 2
839 "*Seconds of wait in `howm-random-walk'."
843 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
846 (defgroup howm-create nil
850 (defcustom howm-prepend nil
851 "*Non nil if new entries should be prepended to previous entries.
852 Otherwise, they are appended."
853 :type '(radio (const :tag "Append" nil)
854 (const :tag "Prepend" t))
857 (defcustom howm-content-from-region nil
858 "*When the value non-nil, selected string is inserted as default content.
859 Unless the value is t, single-line selection is inserted as title instead.
860 This variable is ignored when `transient-mark-mode' is nil."
861 :type '(radio (const :tag "Off" nil)
862 (const :tag "Single line selection is copied as title" 1)
863 (const :tag "Any selection is copied as content" t))
866 (defcustom howm-title-from-search nil
867 "*Non nil if searched keyword is inserted as default title
868 when `howm-create' is called on summary buffer."
872 (defcustom howm-create-here-just nil
873 "*Non nil if `howm-create-here' should insert new entry into cursor position
874 rather than append or prepend."
875 :type '(radio (const :tag "Append or prepend" nil)
876 (const :tag "Just here" t))
879 (defcustom howm-remember-first-line-to-title nil
880 "If non-nil, the first line in `howm-remember' is set to %title
881 and the rest lines are inserted to the position at %cursor in `howm-template.
882 If nil, all the lines are simply inserted at %cursor."
886 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
889 (defgroup howm-viewer nil
890 "External viewers for images, movies, sounds, etc."
893 (defun howm-try-require (feature)
894 (and (locate-library (symbol-name feature))
897 ;; These variables should be renamed.
899 (howm-defcustom-risky howm-view-external-viewer-assoc nil
900 "List of viewer specifications.
901 Each specification must be a cons pair of type and format.
902 Type is a regular expression of file names.
903 Format is a command string in which %s is replaced with file name.
904 This setting is prior to mailcap.
906 This variable is marked as a risky local variable
907 because `howm-viewer-dispatchers' `howm-viewer-indicator'
908 and `howm-viewer-type' accept functions instead of format strings.
911 (setq howm-view-external-viewer-assoc
913 (\"[.]\\(jpg\\|gif\\|png\\)$\" . \"display %s\")
914 (\"[.]dvi$\" . \"xdvi %s\")
917 :type '(alist :key-type regexp :value-type string)
920 (defcustom howm-view-use-mailcap
921 (and (howm-try-require 'mailcap)
922 (fboundp 'mailcap-parse-mailcaps)
923 (fboundp 'mailcap-parse-mimetypes))
924 "*Non nil if external viewers should be selected according to mailcap.
925 Mailcap processing depends on gnus/mailcap, and old FLIM library may
930 (defcustom howm-view-open-by-myself '("text/.*" "application/emacs-lisp")
931 "List of regular expressions for mime types which should be opened normally."
932 :type '(repeat regexp)
935 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
938 (defgroup howm-narrow nil
939 "Narrowing to each entry."
942 (defcustom howm-auto-narrow t
943 "List of commands after which the function `howm-auto-narrow' can work.
944 If the value is t, it means 'always'."
945 :type `(radio (const :tag "Never" nil)
946 (const :tag "Always" t)
947 ,howm-custom-command-list)
950 (mapc (lambda (hook) (custom-add-option hook 'howm-auto-narrow))
951 '(howm-view-open-hook howm-create-hook))
953 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
956 (defgroup howm-efficiency nil
957 "To improve performance, use grep and turn off expensive options."
960 (defcustom howm-refresh-after-save t
961 "*Redraw links after you save howm note."
963 :group 'howm-efficiency)
965 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
968 (defgroup howm-faces nil
973 (howm-defcustom-risky howm-user-font-lock-keywords nil
974 "Font lock keywords for all howm-related buffers.
975 See help of `font-lock-keywords' for details.
976 Note: `howm-menu-font-lock-rules' overrides this variable."
977 ;; :type '(repeat (radio (cons regexp (list (const quote) face))
982 (defcustom howm-use-color t
983 "*If non-nil, highlight tags in howm-mode verbosely."
987 (defface howm-view-hilit-face
988 '((((class color)) (:foreground "red"))
990 "*Face for matched word."
993 (defface howm-view-name-face
994 '((((class color)) (:foreground "white" :background "blue"))
996 "*Face for file name in summary buffer."
999 (defface howm-view-empty-face
1000 '((((class color)) (:background "midnight blue"))
1002 "*Face for empty field in summary buffer."
1005 (defface howm-mode-title-face ;; =
1006 '((((class color)) (:foreground "RoyalBlue"))
1010 (defface howm-mode-ref-face ;; >>>
1011 '((((class color) (background light)) (:foreground "blue"))
1012 (((class color) (background dark)) (:foreground "cyan"))
1014 "*Face for goto link."
1016 (defface howm-mode-keyword-face ;; <<<
1017 '((((class color)) (:foreground "white" :background "blue"))
1019 "*Face for come-from link."
1021 (defface howm-mode-wiki-face ;; [[]]
1022 '((((class color) (background light)) (:foreground "blue"))
1023 (((class color) (background dark)) (:foreground "cyan"))
1025 "*Face for wiki link."
1028 (defface howm-reminder-normal-face
1029 '((((class color)) (:foreground "blue"))
1031 "*Face for normal reminder."
1033 (defface howm-reminder-todo-face
1034 '((((class color) (background light)) (:foreground "purple"))
1035 (((class color) (background dark)) (:foreground "yellow"))
1039 (defface howm-reminder-defer-face
1040 '((((class color)) (:foreground "magenta"))
1044 (defface howm-reminder-deadline-face
1045 '((((class color)) (:foreground "red"))
1047 "*Face for deadline."
1049 (defface howm-reminder-late-deadline-face
1050 '((((class color)) (:background "red" :foreground "black"))
1052 "*Face for late deadline."
1054 (defface howm-reminder-schedule-face
1055 '((((class color) (background light)) (:foreground "dark green"))
1056 (((class color) (background dark)) (:foreground "green"))
1058 "*Face for schedule."
1060 (defface howm-reminder-done-face
1061 '((((class color) (background light)) ())
1062 (((class color) (background dark)) (:foreground "gray"))
1064 "*Face for done reminder."
1066 (defface howm-reminder-today-face
1067 '((((class color)) (:foreground "black" :background "orange"))
1071 (defface howm-reminder-tomorrow-face
1072 '((((class color)) (:foreground "black" :background "pink"))
1074 "*Face for tommorow."
1077 (defface howm-menu-list-face ;; item header in menu-mode list (schedule, todo)
1079 "*Face for list in menu."
1081 (defface howm-menu-key-face ;; shortcut key in menu-mode
1082 '((((class color) (background light)) (:foreground "dark red"))
1083 (((class color) (background dark)) (:foreground "orange"))
1085 "*Face for key binding in menu."
1088 (defvar howm-view-hilit-face 'howm-view-hilit-face
1089 "*Face for matched word.")
1090 (defvar howm-view-name-face 'howm-view-name-face
1091 "*Face for file name in summary buffer.")
1092 (defvar howm-view-empty-face 'howm-view-empty-face
1093 "*Face for empty field in summary buffer.")
1094 (defvar howm-mode-title-face 'howm-mode-title-face
1096 (defvar howm-mode-ref-face 'howm-mode-ref-face
1097 "*Face for goto link.")
1098 (defvar howm-mode-keyword-face 'howm-mode-keyword-face
1099 "*Face for come-from link.")
1100 (defvar howm-mode-wiki-face 'howm-mode-wiki-face
1101 "*Face for wiki link.")
1102 (defvar howm-reminder-normal-face 'howm-reminder-normal-face
1103 "*Face for normal reminder.")
1104 (defvar howm-reminder-todo-face 'howm-reminder-todo-face
1106 (defvar howm-reminder-defer-face 'howm-reminder-defer-face
1108 (defvar howm-reminder-deadline-face 'howm-reminder-deadline-face
1109 "*Face for deadline.")
1110 (defvar howm-reminder-late-deadline-face 'howm-reminder-late-deadline-face
1111 "*Face for late deadline.")
1112 (defvar howm-reminder-schedule-face 'howm-reminder-schedule-face
1113 "*Face for schedule.")
1114 (defvar howm-reminder-done-face 'howm-reminder-done-face
1115 "*Face for done reminder.")
1116 (defvar howm-reminder-today-face 'howm-reminder-today-face
1118 (defvar howm-reminder-tomorrow-face 'howm-reminder-tomorrow-face
1119 "*Face for tommorow.")
1120 (defvar howm-menu-list-face 'howm-menu-list-face
1121 "*Face for list in menu.")
1122 (defvar howm-menu-key-face 'howm-menu-key-face
1123 "*Face for key binding in menu.")
1125 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1128 (defgroup howm-hooks nil
1132 (defcustom howm-mode-hook nil
1133 "Hook run at the end of function `howm-mode'"
1137 (defcustom howm-mode-on-hook nil
1138 "Hook run when `howm-mode' is turned on."
1142 (defcustom howm-mode-off-hook nil
1143 "Hook run when `howm-mode' is turned off."
1147 (defcustom howm-view-open-hook nil
1148 "Hook run when open a note from summary/contents buffer."
1153 (defcustom howm-view-before-open-hook nil
1154 "Hook run before open something from summary or contents buffer."
1158 (defcustom howm-create-file-hook nil
1159 "Hook run when buffer for new note is created."
1163 (defcustom howm-create-hook nil
1164 "Hook run after new note is created and set up."
1169 (defcustom howm-menu-hook nil
1170 "Hook run at the end of `howm-menu-refresh'."
1174 (defcustom howm-congrats-hook nil
1175 "Hook run at the end of `howm-congrats'."
1179 (defcustom howm-after-save-hook nil
1180 "Hook run at the end of `howm-after-save'."
1184 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1187 (defgroup howm-devel nil
1188 "Developers' diagnoses."
1191 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1194 (defgroup howm-experimental nil
1195 "Test of experimental features."
1198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1199 ;; Date format (need refactoring)
1201 (defvar howm-date-separator "-") ;; "-" ==> 2003-10-21
1203 ;; Fix me: redundant (howm-date-* & howm-reminder-*)
1204 ;; (cf.) howm-reminder-regexp-grep-* howm-reminder-today-format
1205 (defvar howm-date-regexp-grep
1206 (concat "[1-2][0-9][0-9][0-9]" howm-date-separator
1207 "[0-1][0-9]" howm-date-separator
1209 (defvar howm-date-regexp
1210 (concat "\\([1-2][0-9][0-9][0-9]\\)" howm-date-separator
1211 "\\([0-1][0-9]\\)" howm-date-separator
1212 "\\([0-3][0-9]\\)"))
1213 (defvar howm-date-regexp-year-pos 1)
1214 (defvar howm-date-regexp-month-pos 2)
1215 (defvar howm-date-regexp-day-pos 3)
1216 (defvar howm-date-format
1217 (concat "%Y" howm-date-separator "%m" howm-date-separator "%d"))
1218 (defvar howm-dtime-body-format
1219 (concat howm-date-format " %H:%M"))
1220 (defvar howm-dtime-format
1221 (concat "[" howm-dtime-body-format "]"))
1222 (defvar howm-insert-date-format "[%s]")
1223 (defvar howm-insert-date-future nil)
1225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1226 ;; Avoid reference to free variable (need refactoring)
1228 (howm-defvar-risky howm-menu-action-arg 'howm-menu-action-arg-name)
1232 (provide 'howm-vars)
1234 ;;; howm-vars.el ends here