我正在尝试使用自定义设置,但它没有按预期工作org-mode 8.2
。Windows 7
我的“Emacs”版本:MARVIN 上的 2012-08-29 的 GNU Emacs 24.2.1 (i386-mingw-nt6.1.7601)
我尝试过的:
〜/.emacs
在文件中~/.emacs
我有(除其他外)这些行:
(if (boundp 'org-mode-user-lisp-path)
(add-to-list 'load-path org-mode-user-lisp-path)
(add-to-list 'load-path (expand-file-name "~/org-mode/org_current/lisp")))
(setq default-directory "C:/Users/mypath/" )
(if (boundp 'org-mode-user-contrib-lisp-path)
(add-to-list 'load-path org-mode-user-contrib-lisp-path)
(add-to-list 'load-path (expand-file-name "~/org-mode/org_current/contrib/lisp/"))
(add-to-list 'load-path (expand-file-name "~/org-mode/morelisp/")))
(require 'icicles)
(require 'dired+)
(require 'org)
(require 'bookmark+)
(load "org")
然后
(load "C:/Users/mypath/org-config/myname_orgmodeconfig.el")
C:/用户/mypath/org-config/myname_orgmodeconfig.el
包含
(add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . org-mode))
;; Standard key bindings
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(if (boundp 'org-user-agenda-files)
(setq org-agenda-files org-user-agenda-files)
(setq org-agenda-files (quote ("~/org"
))))
因此我尝试将路径中的所有 org 文件用作~/org
议程文件。
当我启动时emacs
,我在缓冲区中得到以下结果*Messages
:
Turning OFF Icicle mode...done
Turning ON Icicle mode...done
Turning OFF Icicle mode...done
Turning ON Icicle mode...done
Turning ON Icicle mode...done
Turning OFF Icicle mode...done
Loading c:/Users/mypath/org-mode/org_current/lisp/org.el (source)...done
Loading c:/Users/mypath/org-config/myname_orgmodeconfig.el (source)...done
Loading paren...done
For information about GNU Emacs and the GNU system, type C-h C-a.
问题
因此我假设,由于文件myname_orgmodeconfig.el
已经加载,里面的所有 elisp 代码都应该已经执行,并且还应该设置我的议程文件。
但是启动后议程文件列表是空的。然后当我手动经常文件myname_orgmodeconfig.el
并执行命令eval-buffer
,一切都很好。
我该如何修复它?
答案1
初始帖子(2014年1月15日):
以下内容适用于 Org 版本 8,但我不确定 regexp 变量是何时首次引入的——它可能也适用于早期的 Org 版本。此示例设想主目录中将有.org
and/or文件——.todo
不是子目录。该函数org-agenda-files
爬行变量 中指定的目录org-agenda-files
。另请参阅函数org-files-list
。这些函数是非交互式的,因此M-x ...
无法与它们一起使用。
(setq org-agenda-files (list "~/"))
(setq org-agenda-file-regexp "\\`[^.].*\\.org\\|.todo\\'")
打开 Emacs 后,评估该函数(org-agenda-files)
。
编辑(2014年1月21日):
以下对 Org 版本 8 的源文件进行单词搜索可以说明功能 org-agenda-files
每当另一个函数需要该值时就会调用多变的 org-agenda-files
换句话说,多变的 org-agenda-files
任何时候确定功能 org-agenda-files
叫做。
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org-agenda.el:
314 (string :tag "Headline"))
315 (list :tag "Files to be searched"
316: (const org-agenda-files)
317 (list
318 (const :format "" quote)
...
1529 tsia-down Sort by inactive timestamp, late first
1530 category-keep Keep the default order of categories, corresponding to the
1531: sequence in `org-agenda-files'.
1532 category-up Sort alphabetically by category, A-Z.
1533 category-down Sort alphabetically by category, Z-A.
....
1554 agenda listing for the day. Of the entries without a time indication, keep
1555 the grouped in categories, don't sort the categories, but keep them in
1556: the sequence given in `org-agenda-files'. Within each category sort by
1557 priority.
1558
....
2167 (list
2168 (vector
2169: (if (get 'org-agenda-files 'org-restrict)
2170 "Restricted to single file"
2171 "Edit File List")
2172 '(org-edit-agenda-file-list)
2173: (not (get 'org-agenda-files 'org-restrict)))
2174 "--")
2175: (mapcar 'org-file-menu-entry (org-agenda-files))))
2176 (org-agenda-set-mode-name)
2177 (apply
....
2720 (unless (org-bound-and-true-p org-agenda-keep-restricted-file-list)
2721 ;; There is a request to keep the file list in place
2722: (put 'org-agenda-files 'org-restrict nil))
2723 (setq org-agenda-restrict nil)
2724 (move-marker org-agenda-restrict-begin nil)
....
2742 ;; Establish the restriction, if any
2743 (when (and (not org-agenda-overriding-restriction) restriction)
2744: (put 'org-agenda-files 'org-restrict (list bfn))
2745 (cond
2746 ((eq restriction 'region)
....
2834 (user-error "This is not an Org-mode file"))
2835 (unless restriction
2836: (put 'org-agenda-files 'org-restrict (list bfn))
2837 (org-call-with-arg 'org-timeline arg)))
2838 ((equal org-keys "#") (call-interactively 'org-agenda-list-stuck-projects))
....
3677 (setq org-agenda-contributing-files nil)
3678 (setq org-agenda-columns-active nil)
3679: (org-agenda-prepare-buffers (org-agenda-files nil 'ifmode))
3680 (setq org-todo-keywords-for-agenda
3681 (org-uniquify org-todo-keywords-for-agenda))
....
4141 ;;;###autoload
4142 (defun org-agenda-list (&optional arg start-day span with-hour)
4143: "Produce a daily/weekly view from all files in variable `org-agenda-files'.
4144 The view will be for the current day or week, but from the overview buffer
4145 you will be able to go to other days/weeks.
....
4186 (if (or (eq ndays 7) (eq ndays 14))
4187 org-agenda-start-on-weekday))
4188: (thefiles (org-agenda-files nil 'ifmode))
4189 (files thefiles)
4190 (start (if (or (null org-agenda-start-on-weekday)
....
4308 (put-text-property s (1- (point)) 'org-day-cnt day-cnt))))
4309 (when (and org-agenda-clockreport-mode clocktable-start)
4310: (let ((org-agenda-files (org-agenda-files nil 'ifmode))
4311 ;; the above line is to ensure the restricted range!
4312 (p (copy-sequence org-agenda-clockreport-parameter-plist))
....
4549 (if hdl-only (setq regexp (concat org-outline-regexp-bol ".*?"
4550 regexp))))
4551: (setq files (org-agenda-files nil 'ifmode))
4552 (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives)
4553 (pop org-agenda-text-search-extra-files)
....
4732 ,org-select-this-todo-keyword
4733 current-prefix-arg ,arg)))
4734: (setq files (org-agenda-files nil 'ifmode)
4735 rtnall nil)
4736 (while (setq file (pop files))
....
4780 ;;;###autoload
4781 (defun org-tags-view (&optional todo-only match)
4782: "Show all headlines for all `org-agenda-files' matching a TAGS criterion.
4783 The prefix arg TODO-ONLY limits the search to TODO entries."
4784 (interactive "P")
....
4811 (list 'org-tags-view `(quote ,todo-only)
4812 (list 'if 'current-prefix-arg nil `(quote ,org-agenda-query-string))))
4813: (setq files (org-agenda-files nil 'ifmode)
4814 rtnall nil)
4815 (while (setq file (pop files))
....
5056 (todo-wds (if (member "*" todo)
5057 (progn
5058: (org-agenda-prepare-buffers (org-agenda-files
5059 nil 'ifmode))
5060 (org-delete-all
....
5227
5228 Use a separate line for each org file to check. Or, if you omit the file name,
5229: all files listed in `org-agenda-files' will be checked automatically:
5230
5231 &%%(org-diary)
....
5251 (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry))
5252 (list entry)
5253: (org-agenda-files t)))
5254 (time (org-float-time))
5255 file rtn results)
....
7104 (setq org-agenda-restrict (current-buffer))
7105 (setq org-agenda-overriding-restriction 'subtree)
7106: (put 'org-agenda-files 'org-restrict
7107 (list (buffer-file-name (buffer-base-buffer))))
7108 (org-back-to-heading t)
....
7116 (save-excursion (org-end-of-subtree t t)))
7117 (message "Locking agenda restriction to subtree"))
7118: (put 'org-agenda-files 'org-restrict
7119 (list (buffer-file-name (buffer-base-buffer))))
7120 (setq org-agenda-restrict nil)
....
7133 (setq org-agenda-overriding-restriction nil)
7134 (setq org-agenda-restrict nil)
7135: (put 'org-agenda-files 'org-restrict nil)
7136 (move-marker org-agenda-restrict-begin nil)
7137 (move-marker org-agenda-restrict-end nil)
....
8180 (setq mode-name
8181 (list "Org-Agenda"
8182: (if (get 'org-agenda-files 'org-restrict) " []" "")
8183 " "
8184 '(:eval (org-agenda-span-name org-agenda-current-span))
....
9997 ;;;###autoload
9998 (defun org-agenda-to-appt (&optional refresh filter &rest args)
9999: "Activate appointments found in `org-agenda-files'.
10000 With a \\[universal-argument] prefix, refresh the list of
10001 appointments.
.....
10042 (time-to-days (current-time))))
10043 (org-agenda-restrict nil)
10044: (files (org-agenda-files 'unrestricted)) entries file
10045 (org-agenda-buffer nil))
10046 ;; Get all entries which may contain an appt
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org-bbdb.el:
38 ;;
39 ;; Put the following in /somewhere/at/home/diary.org and make sure
40: ;; that this file is in `org-agenda-files`
41 ;;
42 ;; %%(org-bbdb-anniversaries)
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org-capture.el:
1659 (org-global-tags-completion-table
1660 (if (equal char "G")
1661: (org-agenda-files)
1662 (and file (list file)))))
1663 (org-add-colon-after-tag-completion t)
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org-clock.el:
2268 (setq scope (eval scope)))
2269 ((eq scope 'agenda)
2270: (setq scope (org-agenda-files t)))
2271 ((eq scope 'agenda-with-archives)
2272: (setq scope (org-agenda-files t))
2273 (setq scope (org-add-archive-files scope)))
2274 ((eq scope 'file-with-archives)
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org-id.el:
462 (append
463 ;; Agenda files and all associated archives
464: (org-agenda-files t org-id-search-archives)
465 ;; Explicit extra files
466 (if (symbolp org-id-extra-files)
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org-mobile.el:
46 :group 'org)
47
48: (defcustom org-mobile-files '(org-agenda-files)
49 "Files to be staged for MobileOrg.
50 This is basically a list of files and directories. Files will be staged
..
52 In addition to this, the list may also contain the following symbols:
53
54: org-agenda-files
55 This means include the complete, unrestricted list of files given in
56: the variable `org-agenda-files'.
57 org-agenda-text-search-extra-files
58 Include the files given in the variable
..
60 :group 'org-mobile
61 :type '(list :greedy t
62: (option (const :tag "org-agenda-files" org-agenda-files))
63 (option (const :tag "org-agenda-text-search-extra-files"
64 org-agenda-text-search-extra-files))
..
272 (lambda (f)
273 (cond
274: ((eq f 'org-agenda-files)
275: (org-agenda-files t include-archives))
276 ((eq f 'org-agenda-text-search-extra-files)
277 (delq 'agenda-archives
...
327 (message "Creating agendas...")
328 (let ((inhibit-redisplay t)
329: (org-agenda-files (mapcar 'car org-mobile-files-alist)))
330 (org-mobile-create-sumo-agenda))
331 (message "Creating agendas...done")
...
377 ;; Make an agenda view of flagged entries, but only in the files
378 ;; where stuff has been added.
379: (put 'org-agenda-files 'org-restrict org-mobile-last-flagged-files)
380 (let ((org-agenda-keep-restricted-file-list t))
381 (org-agenda nil "?"))))))
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/org.el:
2145 - a specification of the files to be considered, either a list of files,
2146 or a symbol whose function or variable value will be used to retrieve
2147: a file name or a list of file names. If you use `org-agenda-files' for
2148 that, all agenda files will be scanned for targets. Nil means consider
2149 headings in the current buffer.
....
2176 :type '(repeat
2177 (cons
2178: (choice :value org-agenda-files
2179: (const :tag "All agenda files" org-agenda-files)
2180 (const :tag "Current buffer" nil)
2181 (function) (variable) (file))
....
3595 (put 'org-category 'safe-local-variable #'(lambda (x) (or (symbolp x) (stringp x))))
3596
3597: (defcustom org-agenda-files nil
3598 "The files to be used for agenda display.
3599 Entries may be added to this list with \\[org-agenda-file-to-front] and removed with
....
3614
3615 (defcustom org-agenda-file-regexp "\\`[^.].*\\.org\\'"
3616: "Regular expression to match files for `org-agenda-files'.
3617 If any element in the list in that variable contains a directory instead
3618 of a normal file, all files in that directory that are matched by this
....
3641
3642 (defcustom org-agenda-skip-unavailable-files nil
3643: "Non-nil means to just skip non-reachable files in `org-agenda-files'.
3644 A nil value means to remove them, after a query, from the list."
3645 :group 'org-agenda
....
7020
7021 (defun org-files-list ()
7022: "Return `org-agenda-files' list, plus all open org-mode files.
7023 This is useful for operations that need to scan all of a user's
7024 open and agenda-wise Org files."
7025: (let ((files (mapcar 'expand-file-name (org-agenda-files))))
7026 (dolist (buf (buffer-list))
7027 (with-current-buffer buf
....
11261 (cond
11262 ((null files) (setq files (list (current-buffer))))
11263: ((eq files 'org-agenda-files)
11264: (setq files (org-agenda-files 'unrestricted)))
11265 ((and (symbolp files) (fboundp files))
11266 (setq files (funcall files)))
.....
14009 (if (and files (car files))
14010 files
14011: (org-agenda-files))))))))
14012
14013 (defun org-make-tags-matcher (match)
.....
14496 org-complete-tags-always-offer-all-agenda-tags
14497 (org-global-tags-completion-table
14498: (org-agenda-files))))
14499 org-last-tags-completion-table table
14500 current-tags (org-split-string current ":")
.....
14993 (setq scope (eval scope)))
14994 ((eq scope 'agenda)
14995: (setq scope (org-agenda-files t)))
14996 ((eq scope 'agenda-with-archives)
14997: (setq scope (org-agenda-files t))
14998 (setq scope (org-add-archive-files scope)))
14999 ((eq scope 'file)
.....
17814 (let* ((bfn nil)
17815 (agenda-files (and (eq predicate 'agenda)
17816: (mapcar 'file-truename (org-agenda-files t))))
17817 (filter
17818 (cond
.....
17841 (buffer-list)))))
17842
17843: (defun org-agenda-files (&optional unrestricted archives)
17844 "Get the list of agenda files.
17845 Optional UNRESTRICTED means return the full list even if a restriction
.....
17850 (let ((files
17851 (cond
17852: ((and (not unrestricted) (get 'org-agenda-files 'org-restrict)))
17853: ((stringp org-agenda-files) (org-read-agenda-file-list))
17854: ((listp org-agenda-files) org-agenda-files)
17855: (t (error "Invalid value of `org-agenda-files'")))))
17856 (setq files (apply 'append
17857 (mapcar (lambda (f)
.....
17877 buffer."
17878 (member (or file (buffer-file-name))
17879: (org-agenda-files t)))
17880
17881 (defun org-edit-agenda-file-list ()
17882 "Edit the list of agenda files.
17883 Depending on setup, this either uses customize to edit the variable
17884: `org-agenda-files', or it visits the file that is holding the list. In the
17885 latter case, the buffer is set up in a way that saving it automatically kills
17886 the buffer and restores the previous window configuration."
17887 (interactive)
17888: (if (stringp org-agenda-files)
17889 (let ((cw (current-window-configuration)))
17890: (find-file org-agenda-files)
17891 (org-set-local 'org-window-configuration cw)
17892 (org-add-hook 'after-save-hook
.....
17900 (message "%s" (substitute-command-keys
17901 "Edit list and finish with \\[save-buffer]")))
17902: (customize-variable 'org-agenda-files)))
17903
17904 (defun org-store-new-agenda-file-list (list)
17905 "Set new value for the agenda file list and save it correctly."
17906: (if (stringp org-agenda-files)
17907 (let ((fe (org-read-agenda-file-list t)) b u)
17908: (while (setq b (find-buffer-visiting org-agenda-files))
17909 (kill-buffer b))
17910: (with-temp-file org-agenda-files
17911 (insert
17912 (mapconcat
.....
17919 (let ((org-mode-hook nil) (org-inhibit-startup t)
17920 (org-insert-mode-line-in-empty-file nil))
17921: (setq org-agenda-files list)
17922: (customize-save-variable 'org-agenda-files org-agenda-files))))
17923
17924 (defun org-read-agenda-file-list (&optional pair-with-expansion)
.....
17927 filenames, used by `org-store-new-agenda-file-list' to write back
17928 un-expanded file names."
17929: (when (file-directory-p org-agenda-files)
17930: (error "`org-agenda-files' cannot be a single directory"))
17931: (when (stringp org-agenda-files)
17932 (with-temp-buffer
17933: (insert-file-contents org-agenda-files)
17934 (mapcar
17935 (lambda (f)
.....
17943 ;;;###autoload
17944 (defun org-cycle-agenda-files ()
17945: "Cycle through the files in `org-agenda-files'.
17946 If the current buffer visits an agenda file, find the next one in the list.
17947 If the current buffer does not, find the first agenda file."
17948 (interactive)
17949: (let* ((fs (org-agenda-files t))
17950 (files (append fs (list (car fs))))
17951 (tcf (if buffer-file-name (file-truename buffer-file-name)))
.....
17970 (file-alist (mapcar (lambda (x)
17971 (cons (file-truename x) x))
17972: (org-agenda-files t)))
17973 (ctf (file-truename
17974 (or buffer-file-name
.....
17987
17988 (defun org-remove-file (&optional file)
17989: "Remove current file from the list of files in variable `org-agenda-files'.
17990 These are the files which are being checked for agenda entries.
17991 Optional argument FILE means use this file instead of the current."
.....
18001 (file-truename x))
18002 nil x))
18003: (org-agenda-files t)))))
18004: (if (not (= (length files) (length (org-agenda-files t))))
18005 (progn
18006 (org-store-new-agenda-file-list files)
.....
21087 ["Occur in all agenda files" org-occur-in-agenda-files t]
21088 "--")
21089: (mapcar 'org-file-menu-entry (org-agenda-files t))))))))
21090
21091 ;;;; Documentation
.....
21710 "Call `multi-occur' with buffers for all agenda files."
21711 (interactive "sOrg-files matching: \np")
21712: (let* ((files (org-agenda-files))
21713 (tnames (mapcar 'file-truename files))
21714 (extra org-agenda-text-search-extra-files)
/Users/HOME/Desktop/emacs-trunk-01-19-2014/lisp/org/ox-icalendar.el:
830 ;; `org-check-agenda-file'. Instead we remove any non-existent
831 ;; agenda file from the list.
832: (let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
833 (org-export-async-start
834 (lambda (results)
...
842 ',files)
843 output-files)))
844: (let ((files (org-agenda-files t)))
845 (org-agenda-prepare-buffers files)
846 (unwind-protect
...
865 (interactive)
866 (if async
867: (let ((files (org-remove-if-not 'file-exists-p (org-agenda-files t))))
868 (org-export-async-start
869 (lambda (dummy)
...
872 'icalendar))
873 `(apply 'org-icalendar--combine-files nil ',files)))
874: (apply 'org-icalendar--combine-files nil (org-agenda-files t))))
875
876 (defun org-icalendar-export-current-agenda (file)
...
906 (if file-markers (push pos (cdr file-markers))
907 (push (list file pos) restriction))))))
908: (org-agenda-files nil 'ifmode))))
909
910 (defun org-icalendar--combine-files (restriction &rest files)
答案2
真正的问题如下:
1)显然,由于某些权限问题,我在加载配置文件时遇到了问题(请参阅https://stackoverflow.com/questions/885793/emacs-error-when-calling-server-start/1313577#1313577)中断了我的 .emacs 文件的评估
2)后从外部文件加载我的自定义议程设置(包括议程文件列表),C:/Users/mypath/org-config/myname_orgmodeconfig.el
我的文件中还有一些配置命令.emacs
。其中一个显然覆盖了议程文件列表...
解决方案:
通过将该行放在(load-file "C:/Users/mypath/org-config/myname_orgmodeconfig.el")
我的 .emacs 文件的末尾,我确保自定义设置不会被覆盖。