0

I'm running Emacs in Android under ZShaolin, with whatever the default configuration is. When I open an org-mode file (or try to enable org-mode), I get an error:

(wrong-type-argument stringp (require . t-mouse))

[This seems to be the case whether or not I enable the trackpad (I'm running on a tablet with keyboard)]

Here is the backtrace:

Debugger entered--Lisp error: (wrong-type-argument stringp (require . t-mouse))
  string-match("\\(\\`\\|/\\)org-exp\\(\\.elc\\|\\.el\\)?\\(\\.gz\\)?\\'" (require . t-mouse))
  load-history-filename-element("\\(\\`\\|/\\)org-exp\\(\\.elc\\|\\.el\\)?\\(\\.gz\\)?\\'")
  eval-after-load("org-exp" (add-hook (quote org-export-preprocess-before-normalizing-links-hook) (quote org-remove-file-link-modifiers)))
  org-mode()
  set-auto-mode-0(org-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer Notes.org> "/sdcard/Android/data/com.dropbox.android/files/u139630781/scratch/Org/Notes.org" nil nil "/storage/emulated/legacy/Android/data/com.dropbox.android/files/u139630781/scratch/Org/Notes.org" ((16419 . 51200) 20))
  find-file-noselect("/sdcard/Android/data/com.dropbox.android/files/u139630781/scratch/Org/Notes.org" nil nil t)
  find-file("/sdcard/Android/data/com.dropbox.android/files/u139630781/scratch/Org/Notes.org" t)
  call-interactively(find-file nil nil)
  • 2
    Please do M-x toggle-debug-on-error, trigger the error, and add the backtrace to this question. – Constantine Dec 19 '14 at 3:11
1

Seems like your Emacs has a malformed load-history variable. Its documentation states:

Documentation: Alist mapping loaded file names to symbols and features. Each alist element should be a list (FILE-NAME ENTRIES...), where FILE-NAME is the name of a file that has been loaded into Emacs. The file name is absolute and true (i.e. it doesn't contain symlinks). As an exception, one of the alist elements may have FILE-NAME nil, for symbols and features not associated with any file.

In your case load-history contains an element whose car is not a string but (require . t-mouse). load-history-filename-element expects a file name (a string) and bails.

I don't know what the reason is (and cannot find out because I don't have an Android device) , but we can try to get around this by creating a slightly more robust version of load-history-filename-element:

(defun load-history-filename-element (file-regexp)
  "Get the first elt of `load-history' whose car matches FILE-REGEXP.
        Return nil if there isn't one."
  (let* ((loads load-history)
         (load-elt (and loads (car loads))))
    (save-match-data
      (while (and loads
                  (or (null (car load-elt))
                      (not (and (stringp (car load-elt)) ; new condition
                                (string-match file-regexp (car load-elt))))))
        (setq loads (cdr loads)
              load-elt (and loads (car loads)))))
    load-elt))

For the record, this is the original version (Emacs 24.4.1):

(defun load-history-filename-element (file-regexp)
  "Get the first elt of `load-history' whose car matches FILE-REGEXP.
    Return nil if there isn't one."
  (let* ((loads load-history)
         (load-elt (and loads (car loads))))
    (save-match-data
      (while (and loads
                  (or (null (car load-elt))
                      (not (string-match file-regexp (car load-elt)))))
        (setq loads (cdr loads)
              load-elt (and loads (car loads)))))
    load-elt))

All of this is a bit of a shot in the dark, but I hope it helps.

  • Thanks! That indeed works. Now I can meaningfully interact with org-mode files on my tablet (if I edit the file in the dropbox directory, I can have changes propagate back via MobileOrg to my other devices (i.e. desktop computers).) This is very useful. – emacsomancer Dec 19 '14 at 19:34
  • Hmm...actually getting the changes to propogate back to my desktop isn't working quite as I had wanted, but that's beyond the scope of emacs.stackexchange I think. – emacsomancer Dec 19 '14 at 20:16
1

For the record: I have dug up the root cause for this one. It is not for ZShaolin build, but rather, for Termux build of Emacs, but the source of the broken load-history entry is the same, it's an Emacs bug resulting from running undumped, which Android builds necessarily have to do.

See https://github.com/termux/termux-packages/issues/423 for the full story.

The most general solution appears to be commenting out the line (setq current-load-list nil) in /usr/share/emacs/<version>/loadup.el -- the presence of this line is intended to excise loadup.el from load-history with emacs that is dumped into a single binary with the lisp components during compilation. On Android, with the requirement that executables must be PIE, a dumped binary will simply not run, so both the ZShaolin and Termux builds of emacs run undumped, and this line results in the creation of a bogus load-history entry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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