3

EDIT: Now I can see the error only happens if I include certain code to do an automatic push, adopted from https://gist.github.com/3111823. It seems that this block of code wants to use org-mobile-files-alist while it hasn't been initialized, because 'org is set to have an async loading by default. No matter whether I put the code in init or config when I require 'org, it doesn't seem to recognize the variable. Another person seems to be encountering the same error, using the auto-push code below, as seen on github.

Unfortunately if I put the code after (package-initialize) it doesn't seem to run at all(i.e. no automatic push no matter what).

The code to do automatic push:

  ;; https://gist.github.com/3111823 ASYNC org mobile push...
(require 'gnus-async) 
;; Define a timer variable
(defvar org-mobile-push-timer nil
  "Timer that `org-mobile-push-timer' used to reschedule itself, or nil.")
;; Push to mobile when the idle timer runs out
(defun org-mobile-push-with-delay (secs)
  (when org-mobile-push-timer
    (cancel-timer org-mobile-push-timer))
  (setq org-mobile-push-timer
        (run-with-idle-timer
        (* 1 secs) nil 'org-mobile-push)))
;; After saving files, start an idle timer after which we are going to push 
(add-hook 'after-save-hook 
(lambda () 
  (if (or (eq major-mode 'org-mode) (eq major-mode 'org-agenda-mode))
    (dolist (file (org-mobile-files-alist))
      (if (string= (expand-file-name (car file)) (buffer-file-name))
          (org-mobile-push-with-delay 25)))
    )))

The code to initialize org mode asynchronously:

(require 'package)
(setq package-enable-at-startup nil)
(package-initialize)
(require 'org)
(require 'ox)
(require 'ox-beamer)
(require 'ox-latex)
(setq org-export-async-debug nil)

I'm new to Emacs and I'm actually using a starter kit called spacemacs. So I'm not sure how to fix this problem even after two hours' of trying...


I'm seeing the error Symbol's function definition is void: org-mobile-files-alist when performing certain operations. Strangely, the error doesn't occur again after I execute org-mobile-push or org-mobile-pull at least once. The nuisance is that it doesn't seem to only influence org mobile itself, but also interferes with other functionalities such as archiving. Now whenever I run C-c C-x C-a I'll get this error and the entry will not be removed from its original .org file, although it indeed does get archived into the .org_archive file. Thus if I try to archive multiple times, the entry gets repeated in the .org_archive file but it still remains in the original file. It seems that the process of removing the entry and then saving the file gets interrupted by this error.

An example:

Copied: Subtree(s) with 262 characters
Saving file /Users/JX/Dropbox/orgmode/Personal.org_archive...
Wrote /Users/JX/Dropbox/orgmode/Personal.org_archive
let: Symbol's function definition is void: org-mobile-files-alist

I already set my org-mobile-files variable. However it seems that for some reasons it doesn't get picked up until I execute org-mobile-push or org-mobile-pull manually.

org-mobile-directory "/Users/JX/Dropbox/MobileOrg"
org-mobile-files (quote (org-agenda-files))

1 Answer 1

1

Sounds like you need to require the library in which org-mobile-files-alist is defined.

The fact that it is defined after you use org-mobile-push or org-mobile-pull is no doubt because those are autoloaded. IOW when you try to use them Emacs automatically loads the library that defines them, and that has the result of defining org-mobile-files-alist as well.

(If you are using the package system to load such code, instead of, say, putting the code in your load-path and using require, then be sure you use package-initialize.)

2
  • It seems that org-mobile-files-alist is defined in 'org itself as there's no separate 'org-mobile package... I've located the code that caused the error and tried to move it after package-initialize. But doing that makes the code not working at all. Please see my edit. Sorry as I'm new to Emacs and can't really figure out what's going on here...
    – xji
    May 23, 2015 at 18:06
  • You have added a function to after-save-hook that references a variable that is not defined when the hook is run. Load org before adding that function to the hook. (And I don't think you need both an explicit require and a package-initialize.) The bottom line is that you need to load Org before you can use this variable.
    – Drew
    May 23, 2015 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.