Search code examples
emacswindows-7elispwindows-10

(define-error (quote gv-invalid-place) "%S is not a valid place expression")


When I load emacs, it gives me this error using --debug-init after adding cl-lib.el:

Debugger entered--Lisp error: (void-function gv-define-simple-setter)
  (gv-define-simple-setter buffer-file-name set-visited-file-name t)
  eval-buffer(#<buffer  *load*<2>> nil "d:/Tools/Emacs-24.3/cl-lib/cl-lib.el" nil t)  ; Reading at buffer position 23391
  load-with-code-conversion("d:/Tools/Emacs-24.3/cl-lib/cl-lib.el" "d:/Tools/Emacs-24.3/cl-lib/cl-lib.el" nil nil)
  load("d:/Tools/Emacs-24.3/cl-lib/cl-lib.el")
  mapc(load ("d:/Tools/Emacs-24.3/cl-lib/cl-lib.el"))
  eval-buffer(#<buffer  *load*> nil "c:/Users/Psalm3_3/.emacs" nil t)  ; Reading at buffer position 76
  load-with-code-conversion("c:/Users/Psalm3_3/.emacs" "c:/Users/Psalm3_3/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\262

This is the gv.el file I am using:

https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/gv.el

Does anyone have any suggestions? TIA.

UPDATE:

Here is the original error I was getting:

Debugger entered--Lisp error: (file-error "Cannot open load file" "cl-lib")
  require(cl-lib)
  eval-buffer(#<buffer  *load*<2>> nil "d:/Tools/emacs-24.3/site-lisp/desktop.el" nil t)  ; Reading at buffer position 5870
  load-with-code-conversion("d:/Tools/emacs-24.3/site-lisp/desktop.el" "d:/Tools/emacs-24.3/site-lisp/desktop.el" nil nil)
  load("d:/Tools/emacs-24.3/site-lisp/desktop.el")
  mapc(load ("d:/Tools/emacs-24.3/site-lisp/desktop.el"))
  eval-buffer(#<buffer  *load*> nil "c:/Users/Psalm3_3/.emacs" nil t)  ; Reading at buffer position 549
  load-with-code-conversion("c:/Users/Psalm3_3/.emacs" "c:/Users/Psalm3_3/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\262

Here is my .emacs file:

(mapc 'load (file-expand-wildcards "D:/Tools/Emacs-24.3/cl-lib/cl-lib.el"))

;; Require Common Lisp. (cl in <=24.2, cl-lib in >=24.3.)
(if (require 'cl-lib nil t)
  (progn
    (defalias 'cl-block-wrapper 'identity)
    (defalias 'member* 'cl-member)
    (defalias 'adjoin 'cl-adjoin))
  ;; Else we're on an older version so require cl.
  (require 'cl))

;; Load lisp files on start
(mapc 'load (file-expand-wildcards "D:/Tools/emacs-24.3/site-lisp/flymake.el"))
(mapc 'load (file-expand-wildcards "D:/Tools/emacs-24.3/site-lisp/csharp-mode.el"))
(mapc 'load (file-expand-wildcards "D:/Tools/emacs-24.3/site-lisp/desktop.el"))
(mapc 'load (file-expand-wildcards "D:/Tools/emacs-24.3/site-lisp/session.el"))

;; setup load-path
(add-to-list 'load-path "D:/Tools/emacs-24.3/site-lisp")

;; TABS for C
(setq-default c-indent-tabs-mode t     ; Pressing TAB should cause indentation
                c-indent-level 4         ; A TAB is equivilent to four spaces
                c-argdecl-indent 0       ; Do not indent argument decl's extra
                c-tab-always-indent t
                backward-delete-function nil) ; DO NOT expand tabs when deleting
  (c-add-style "my-c-style" '((c-continued-statement-offset 4))) ; If a statement continues on the next line, indent the continuation by 4
  (defun my-c-mode-hook ()
    (c-set-style "my-c-style")
    (c-set-offset 'substatement-open '0) ; brackets should be at same indentation level as the statements they open
    (c-set-offset 'inline-open '+)
    (c-set-offset 'block-open '+)
    (c-set-offset 'brace-list-open '+)   ; all "opens" should be indented by the c-indent-level
    (c-set-offset 'case-label '+))       ; indent case labels by c-indent-level, too
(require 'csharp-mode)
(setq auto-mode-alist
      (append '(("\\.cs$" . csharp-mode)) auto-mode-alist))
(defun my-csharp-mode-fn ()
  "function that runs when csharp-mode is initialized for a buffer."
  (setq default-tab-width 4)
  ; Set indentation level to 4 spaces (instead of 2)
  (setq c-basic-offset 4)
  ; Set the extra indentation before a substatement (e.g. the opening brace in
  ; the consequent block of an if statement) to 0 (instead of '+)
  (c-set-offset 'substatement-open 0)
  (setq-default c-basic-offset 4)
)
(add-hook  'csharp-mode-hook 'my-csharp-mode-fn t)
(add-hook 'c-mode-hook 'my-c-mode-hook)
(add-hook 'c++-mode-hook 'my-c-mode-hook)

(global-set-key "\C-cg" 'goto-line)
(global-set-key "\C-cy" '(lambda ()
                         (interactive)
                         (popup-menu 'yank-menu)))
(put 'upcase-region 'disabled nil)
;; Always use spaces instead of tabs
(setq-default indent-tabs-mode nil)

(defun FindNextDbl ()
  "move to next doubled word, ignoring <...> tags" (interactive)
  (re-search-forward "\\<\\([z-z]+\\)\\([\\n \\t]\\|<[^>]+>\\)+\\1\\?"))

(define-key global-map "\C-x\C-d" 'FindNextDbl)

;; Search all open buffers
(defun my-multi-occur-in-matching-buffers (regexp &optional allbufs)
  "Show all lines matching REGEXP in all buffers."
  (interactive (occur-read-primary-args))
  (multi-occur-in-matching-buffers ".*" regexp))
(global-set-key (kbd "M-s /") 'my-multi-occur-in-matching-buffers)

(setq x-select-enable-clipboard t)

;; Copy list of all open buffers to clipboard: see http://stackoverflow.com/questions/10537265/emacs-save-current-buffer-list-to-a-text-file
(defun copy-open-files ()
  "Add paths to all open files to kill ring"
  (interactive)
  (kill-new (mapconcat 'identity
                       (delq nil (mapcar 'buffer-file-name (buffer-list)))
                       "\n"))
  (message "List of files copied to kill ring"))

;; save my desktop
(desktop-save-mode 1)

;; auto-reload modified files
(global-auto-revert-mode t)

;; put save files in back dir (see http://www.emacswiki.org/emacs/BackupDirectory)
(setq
   backup-by-copying t      ; don't clobber symlinks
   backup-directory-alist
    '(("." . "~/.saves"))    ; don't litter my fs tree
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)       ; use versioned backups

;; move to window based on arrow keys
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <left>") 'windmove-left)

;; incremental completion
(require 'helm-config)
(helm-mode 1)

;; http://stackoverflow.com/questions/275842/is-there-a-repeat-last-command-in-emacs
(defun describe-last-function()
  (interactive)
  (describe-function last-command))

;; get path of present buffer, see http://stackoverflow.com/questions/3669511/the-function-to-show-current-files-full-path-in-mini-buffer
(defun show-file-name ()
  "Show the full path file name in the minibuffer."
  (interactive)
  (message (buffer-file-name)))

(global-set-key [C-f1] 'show-file-name) ; Or any other key you want

;; generate guids
(require 'guid)

UPDATE 2:

Thank you for the excellent post, @Thomas. This is what I've updated the start of my .emacs file to:

;; setup load-path
(add-to-list 'load-path "C:/Tools/emacs-24.3/site-lisp/gv.el")
(require 'gv)
(add-to-list 'load-path "D:/Tools/Emacs-24.3/cl-lib")
(add-to-list 'load-path "C:/Tools/emacs-24.3/site-lisp")

;; Load lisp files on start
(mapc 'load (file-expand-wildcards "C:/Tools/emacs-24.3/site-lisp/flymake.el"))
(mapc 'load (file-expand-wildcards "C:/Tools/emacs-24.3/site-lisp/csharp-mode.el"))
(mapc 'load (file-expand-wildcards "C:/Tools/emacs-24.3/site-lisp/desktop.el"))
(mapc 'load (file-expand-wildcards "C:/Tools/emacs-24.3/site-lisp/session.el"))

Now this is the error I'm getting:

Debugger entered--Lisp error: (void-variable defun-declarations-alist)
  (assq (quote gv-expander) defun-declarations-alist)
  (or (assq (quote gv-expander) defun-declarations-alist) (let ((x (\` (gv-expander (\, (apply-partially ... ...)))))) (push x macro-declarations-alist) (push x defun-declarations-alist)))
  eval-buffer(#<buffer  *load*<2>> nil "d:/Tools/Emacs-24.3/site-lisp/gv.el" nil t)  ; Reading at buffer position 8332
  load-with-code-conversion("d:/Tools/Emacs-24.3/site-lisp/gv.el" "d:/Tools/Emacs-24.3/site-lisp/gv.el" nil t)
  require(gv)
  eval-buffer(#<buffer  *load*> nil "c:/Users/Psalm3_3/.emacs" nil t)  ; Reading at buffer position 96
  load-with-code-conversion("c:/Users/Psalm3_3/.emacs" "c:/Users/Psalm3_3/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\262

Sorry, I'm pretty new at LISP.


Solution

  • The code you have for cl-lib looks very weird. If you have Emacs≥24.3 then you already have cl-lib builtin. And if you have something older then you can't use Emacs-24.3's cl-lib (you have to use GNU ELPA's cl-lib instead, but if it's sufficiently older you won't have GNU ELPA support builtin either, so all in all you're better up upgrading your Emacs to 24.3 or more recent).

    If your Emacs is 24,1 or 24.2, then I recommend you just install cl-lib via M-x package-install RET and then add

    (package-initialize)
    

    at the beginning of your ~/.emacs which will properly setup autoloads for those packages you install via package.el (such as cl-lib above).

    The block that starts with (if (require 'cl-lib ...) ...) looks like an ugly hack to work around a problem you mis-understood. Just remove it.

    Also, remove flymake.el and desktop.el from your site-lisp, the version that comes with Emacs is probably more up-to-date.