0

I want to test a new configuration from emacs for that case I begin with this:

emacs -q --load ".emacs.jesus.d/init.el" --debug-init

it works and I load the emacs file, until I started to download packages from MElPA, in that case I allways get

Scan error: "Unbalanced parentheses", 7659, 14295

My emacs configuration file until loading things is like this:

;; Allow to run n instances of emacs server
(setq server-use-tcp t)
;; emacs --daemon=work
;; emacsclient --server-file=work -c -n

;; Allow  n configuration directories
;; emacs -q --load "/path/to/init.el"
(setq user-init-file (or load-file-name (buffer-file-name)))
(setq user-emacs-directory (file-name-directory user-init-file))
(setq package-user-dir (concat user-emacs-directory "packages"))
;; Using MELPA for packages
(when (>= emacs-major-version 24)
  (require 'package)
  (when (>= emacs-major-version 24)
    (setq package-archives '(("melpa" . "http://melpa.org/packages/")))))

;; Load necessary packages

(package-initialize)
(setq my-required-packages
      (list
            ;; Emacs General packages https://melpa.org/#/
            'ivy
            'expand-region ;; Increase selected region by semantic units
            'wrap-region ;;  Emacs minor mode to wrap region with tag or punctuations 
            'exec-path-from-shell ;;  Make Emacs use the $PATH set up by the user's shell 
            'visual-regexp ;;  A regexp/replace command for Emacs with interactive visual feedback 
            'buffer-move ;; used for rotating buffers
            'visual-regexp-steroids ;;  Extends visual-regexp to support other regexp engines 
            'ido-vertical-mode ;;  makes ido-mode display vertically 
            'yafolding ;;  Yet another folding extension for Emacs 
            's ;;  The long lost Emacs string manipulation library.            
            'sourcemap ;;   Sourmap parser in Emacs Lisp 
            'projectile ;; Project Interaction Library for Emacs http://projectile.readthedocs.io
            'f ;;  Modern API for working with files and directories in Emacs 
            'jump ;; build functions which contextually jump between files
            'discover ;; discover more of Emacs
            'dired-details ;; hide or show the file and directory detail
            'ibuffer-vc ;;  Let Emacs' ibuffer-mode group files by git project etc., and show file state 
            'auto-compile ;;  Automatically compile Emacs Lisp libraries 
            'yaml-mode ;;  The emacs major mode for editing files in the YAML data serialization format. 
            'undo-tree ;; Treat undo history as a tree
            'smartscan ;; Quickly jumps between other symbols found at point in Emacs
            'discover-my-major ;;  Discover key bindings and their meaning for the current Emacs major mode 
            'goto-chg ;; Goto last change in current buffer
            'anzu ;; displays current match and total matches information
            'fullframe ;;  Advice commands to execute fullscreen, restoring the window setup when exiting. 
            'dash ;;  A modern list library for Emacs 
            'popup ;;  Visual Popup Interface Library for Emacs 
            'company ;; Complete anything ;-)
            'cl-lib ;; Properly prefixed CL functions and macros
            'eldoc ;; the argument list of the function call you are currently writing
            'evil ;; Evil is an extensible vi layer for Emacs
            'sh-script ;; The major mode for editing Unix and GNU/Linux shell script code
            'neotree ;;  A emacs tree plugin like NerdTree for Vim. 
            'sx ;; Stackoverflow mode ;-)
        'duplicate-thing ;; duplicate current line
            'clean-aindent-mode ;; Emacs extension for simple indent and unindent
            'comment-dwim-2 ;;  A replacement for the emacs' built-in command comment-dwim 
            'dtrt-indent ;; A minor mode that guesses the indentation offset originally used for creating source code
            'ws-butler ;;  Unobtrusively trim extraneous white-space *ONLY* in lines edited. 
            'iedit ;; Emacs minor mode and allows you to edit one occurrence of some text in a buffer
            'smartparens ;; Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
            'volatile-highlights ;; Minor mode for visual feedback on some operations.
            'zygospore ;; reversible C-x 1 for Emacs
        'fliplr
        ;; Programming 
            'anaconda-mode ;; Python IDE
            'company-anaconda ;; Python ide -completions
        'docker
        ;; GIT
        'magit ;; git on emacs
            'magit-gerrit ;; gerrit mode for emacs
        'git-timemachine ;; Walk through git revisions of a file
        ;; keep latest org-mode
            'org ;; Go and use 
        ;; Themes https://emacsthemes.com/
            'green-phosphor-theme
            'gotham-theme
        'solarized-theme))

(dolist (package my-required-packages)
  (when (not (package-installed-p package))
    (package-refresh-contents)
    (package-install package)))

If I start the emacs lisp interpreter I get:

ELISP> user-emacs-directory
"/home/anquegi/.emacs.jesus.d/"
ELISP> package-user-dir
"/home/anquegi/.emacs.jesus.d/packages"
ELISP> my-required-packages
(ivy expand-region wrap-region exec-path-from-shell visual-regexp buffer-move visual-regexp-steroids ido-vertical-mode yafolding s sourcemap projectile f jump discover dired-details ibuffer-vc auto-compile yaml-mode undo-tree smartscan discover-my-major goto-chg anzu fullframe dash popup company cl-lib eldoc evil sh-script neotree sx duplicate-thing clean-aindent-mode comment-dwim-2 dtrt-indent ws-butler iedit smartparens volatile-highlights zygospore fliplr anaconda-mode company-anaconda docker magit magit-gerrit git-timemachine org green-phosphor-theme gotham-theme solarized-theme)

then when I try to execute the dolist term with C-x C-e I get this:

Debugger entered--Lisp error: (scan-error "Unbalanced parentheses" 7659 14295)
  scan-sexps(45 14294)
  forward-sexp(14294)
  custom-save-delete(custom-set-variables)
  custom-save-variables()
  custom-save-all()
  customize-save-variable(package-selected-packages nil)
  package--save-selected-packages(nil)
  package--user-selected-p(ivy)
  package-install(ivy)
  (progn (package-refresh-contents) (package-install package))
  (if (not (package-installed-p package)) (progn (package-refresh-contents) (package-install package)))
  (while --dolist-tail-- (setq package (car --dolist-tail--)) (if (not (package-installed-p package)) (progn (package-refresh-contents) (package-install package))) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (let ((--dolist-tail-- my-required-packages) package) (while --dolist-tail-- (setq package (car --dolist-tail--)) (if (not (package-installed-p package)) (progn (package-refresh-contents) (package-install package))) (setq --dolist-tail-- (cdr --dolist-tail--))))
  eval((let ((--dolist-tail-- my-required-packages) package) (while --dolist-tail-- (setq package (car --dolist-tail--)) (if (not (package-installed-p package)) (progn (package-refresh-contents) (package-install package))) (setq --dolist-tail-- (cdr --dolist-tail--)))) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

also I tried to intall the ivy package with package-install and give the same error, but if I started emacs without any option i.e. using the normal .emacs.d/init.el it works as expected

if I do

2016-10-26 10:55:28 ☆ toshiba in ~ ○ → mv .emacs.d .emacs.old.d

2016-10-26 10:55:53 ☆ toshiba in ~ ○ → mv .emacs.jesus.d/ .emacs.d

2016-10-26 10:56:28 ☆ toshiba in ~ ○ → emacs

It works well

6
  • Scan error: "Unbalanced parentheses", 7659, 14295 which line is it?
    – xuhdev
    Commented Oct 25, 2016 at 3:00
  • It doesn t say line. It is with the ivy package, but this code works on emacs.d directory
    – anquegi
    Commented Oct 25, 2016 at 5:22
  • The first step I would take is to comment out the 'ivy from the list, and see if the problem moves on to 'expand-region. This way we we can narrow it down to 'does this break on the first package' rather than 'does this break on ivy'. Can you confirm the version number for emacs? The stack backtrace shows that the package-install is calling custom-save-all to save the customized variables, presumably to .emacs.jesus.d/init.el, so this may have nothing at all to do with loading packages, and everything to do with custom variables.
    – icarus
    Commented Oct 25, 2016 at 6:25
  • Ok, thanks I will test it and update my question
    – anquegi
    Commented Oct 25, 2016 at 6:27
  • The call (custom-save-delete 'custom-set-variables) is looking for a form that has custom-set-variables as its car. It checks that the buffer is valid. Is there any more in the file that you have not shown us, as there is less than 5000 characters in the pasted bit, but if I understand the error message it is saying the region between positions 7659 and 14295 has mismatched parentheses.
    – icarus
    Commented Oct 25, 2016 at 6:38

2 Answers 2

1

The problem is that specifying user-emacs-directory that way is just a broken workaround - see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=15539 for details. You can also take the patch from there which solves the problem properly.

0

The issue appears to be that the file .emacs.jesus.d/init.el file in the part that is not shown has characters that are not valid elisp. The package code wants to save some custom variables, and therefore wants to edit this file as there is not a separate custom-file. The edits want to remove any existing custom-set-variables, and add a new one. It is failing due to the invalid elisp.

Your Answer

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

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