{"action":"created","issue":{"url":"https://api.github.com/repos/termux/termux-packages/issues/423","repository_url":"https://api.github.com/repos/termux/termux-packages","labels_url":"https://api.github.com/repos/termux/termux-packages/issues/423/labels{/name}","comments_url":"https://api.github.com/repos/termux/termux-packages/issues/423/comments","events_url":"https://api.github.com/repos/termux/termux-packages/issues/423/events","html_url":"https://github.com/termux/termux-packages/issues/423","id":174307741,"number":423,"title":"A really bizarre bug in emacs.","user":{"login":"Mihara","id":400675,"avatar_url":"https://avatars.githubusercontent.com/u/400675?v=3","gravatar_id":"","url":"https://api.github.com/users/Mihara","html_url":"https://github.com/Mihara","followers_url":"https://api.github.com/users/Mihara/followers","following_url":"https://api.github.com/users/Mihara/following{/other_user}","gists_url":"https://api.github.com/users/Mihara/gists{/gist_id}","starred_url":"https://api.github.com/users/Mihara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mihara/subscriptions","organizations_url":"https://api.github.com/users/Mihara/orgs","repos_url":"https://api.github.com/users/Mihara/repos","events_url":"https://api.github.com/users/Mihara/events{/privacy}","received_events_url":"https://api.github.com/users/Mihara/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/termux/termux-packages/labels/bug%20report","name":"bug report","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-08-31T15:42:06Z","updated_at":"2016-09-06T07:11:03Z","closed_at":null,"body":"Frankly, I'm not sure whom exactly is to blame for this one, but since it only manifests on android, and apparently, not just under Termux, I think I'll start here.\r\n\r\nThe symptoms are like this: You have your init.el setup, which works fine on Linux or Windows or Mac or wherever, and attempt to use it under Android. Everything seems to be working, until you start using a mode that does something clever with files. In my case, it was tramp-mode in some cases, and magit in others. You get a bizarre error message, saying that it choked somewhere deep inside the standard library, and the offending function is always `load-history-filename-element` with the error `(wrong-type-argument stringp (...))` -- the argument is usually different, in my case it was always `(require . bytecomp)` If you delete all your compiled elc files and start again, a *different* package starts choking on it. Loading with `emacs -q` presents no issue, however, though *probably* it's because the packages that tripped over it are not being loaded anymore.\r\n\r\nI really am not sure who's at fault, considering that on desktop Linux the problem never appears. I almost gave up, but then I stumbled onto this StackExchange discussion: https://emacs.stackexchange.com/questions/5552/emacs-on-android-org-mode-error-wrong-type-argument-stringp-require-t\r\n\r\nThe logic is sound. Applying the patch effectively shuts the problem down! And yet, on desktop Linux, the `load-history` list looks almost the same and contains the *same* types of non-string values, but the crash never occurs. Even though the code of the function is identical.\r\n\r\nI have a suspicion that since the problem is Android specific, the real cause is somewhere in the C code, and on desktop Linux the problem never triggers because the ordering of the elements in `load-history` is somehow different, so that the regexp always finds a matching file before it stumbles into any of the non-string elements of the list. Unfortunately I don't have the expertise to go diving into C code.\r\n\r\nFor the record here's my patch:\r\n\r\n    ;; patch-load-history.el -- Patch load-history-filename-element\r\n\r\n    ;;; Commentary:\r\n\r\n    ;; On Termux and apparently, certain other Android builds of Emacs,\r\n    ;; something weird happens to load-history.\r\n\r\n    ;; Which causes crashes all over, centering around this function.\r\n    ;; This is a bandaid that prevents those crashes without addressing\r\n    ;; the root cause of the problem.\r\n\r\n    ;;; Code:\r\n\r\n    (defun l-h-f-e-patch (orig-fun file-regexp)\r\n      \"Get the first elt of `load-history' whose car matches FILE-REGEXP.\r\n            Return nil if there isn't one.\"\r\n      (let* ((loads load-history)\r\n             (load-elt (and loads (car loads))))\r\n        (save-match-data\r\n          (while (and loads\r\n                      (or (null (car load-elt))\r\n                          (not (and (stringp (car load-elt)) ; new condition\r\n                                    (string-match file-regexp (car load-elt))))))\r\n            (setq loads (cdr loads)\r\n                  load-elt (and loads (car loads)))))\r\n        load-elt))\r\n\r\n    (advice-add 'load-history-filename-element :around #'l-h-f-e-patch)\r\n\r\n    (provide 'patch-load-history)\r\n\r\n    ;;; patch-load-history.el ends here\r\n"},"comment":{"url":"https://api.github.com/repos/termux/termux-packages/issues/comments/244867768","html_url":"https://github.com/termux/termux-packages/issues/423#issuecomment-244867768","issue_url":"https://api.github.com/repos/termux/termux-packages/issues/423","id":244867768,"user":{"login":"Mihara","id":400675,"avatar_url":"https://avatars.githubusercontent.com/u/400675?v=3","gravatar_id":"","url":"https://api.github.com/users/Mihara","html_url":"https://github.com/Mihara","followers_url":"https://api.github.com/users/Mihara/followers","following_url":"https://api.github.com/users/Mihara/following{/other_user}","gists_url":"https://api.github.com/users/Mihara/gists{/gist_id}","starred_url":"https://api.github.com/users/Mihara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mihara/subscriptions","organizations_url":"https://api.github.com/users/Mihara/orgs","repos_url":"https://api.github.com/users/Mihara/repos","events_url":"https://api.github.com/users/Mihara/events{/privacy}","received_events_url":"https://api.github.com/users/Mihara/received_events","type":"User","site_admin":false},"created_at":"2016-09-06T07:11:03Z","updated_at":"2016-09-06T07:11:03Z","body":"@fornwall It worked with the above command, and inspecting the deb shows that my patch is in.\r\n\r\nNow let me doublecheck everything. :)"}}
{"actor":{"display_login":"Mihara"}}