(define-error (quote gv-invalid-place) "%S is not a valid place expression")
(define-error (quote gv-invalid-place) "%S is not a valid place expression")
当我加载 emacs 时,在添加 cl-lib.el:
后使用 --debug-init 时出现此错误
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 "52
这是我正在使用的 gv.el 文件:
https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/gv.el
有人有什么建议吗? TIA.
更新:
这是我得到的原始错误:
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 "52
这是我的 .emacs 文件:
(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
(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)
;;
(defun describe-last-function()
(interactive)
(describe-function last-command))
;; get path of present buffer, see
(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)
更新 2:
感谢您的出色 post,@Thomas。这就是我将 .emacs 文件的开头更新为:
;; 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"))
现在这是我得到的错误:
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 "52
抱歉,我是 LISP 新手。
错误源于 Emacs 无法加载正确的文件。您正在尝试在此处手动加载一堆单个文件。但是,这不是应该加载底层包的方式。
通常,软件包附带安装说明,通常需要您在 init 文件中添加一些行:修改加载路径,设置 when 加载软件包的条件,并添加命令 how 来加载包。这些几乎从来没有涉及直接调用非常低级的 load
函数。
如果您查看原始错误,堆栈跟踪会告诉您它是由 (require cl-lib)
抛出的。 require
是 Emacs 在必要时加载文件的机制之一。要使其正常工作,您不需要直接加载相关文件。您所要做的就是设置您的加载路径,以便 Emacs 可以找到所引用的文件。
例如,对于您的 cl-lib.el
文件,您可以这样做:
(add-to-list 'load-path "D:/Tools/Emacs-24.3/cl-lib")
您将此行添加到您的 init 文件中(当然在 Emacs 尝试加载 cl-lib 之前的某个点。
require
的对应部分是 provide
。如果您查看 gv.el
的源代码并一直滚动到底部,您会发现最后一行:
(provide 'gv)
这意味着他的文件提供了 "feature" gv
,并且每当您编写 (require 'gv)
时,您就是在告诉 Emacs 您需要该功能。如果 Emacs 已经知道它,那么一切都很好而且花花公子;如果没有,Emacs 将尝试加载该功能。因此,要加载 gv.el
文件的内容,您所要做的就是将以下内容添加到您的初始化文件中:
(add-to-list 'load-path "/path/to/directory/containing/gv.el")
(require 'gv)
有关 require
和 provide
的更多信息,请参阅 Emacs Manual。
但让我重申上面的一点:通常,软件包附带特定的安装说明,通常 "hidden" 在源代码文件顶部的长注释部分中。因此,无论何时您要手动将包添加到您的设置中,请务必检查此类说明。
旁注:
(mapc 'load <something>)
只有在 <something>
扩展为 文件列表 时才真正有意义。如果像您的情况一样,<something>
只是一个文件,您不妨只写:
(load <something>)
但是,load
是一个低级功能,您作为最终用户几乎不需要。
你的 cl-lib 代码看起来很奇怪。如果您的 Emacs ≥ 24.3,那么您已经内置了 cl-lib。如果你有旧的东西,那么你不能使用 Emacs-24.3 的 cl-lib(你必须使用 GNU ELPA 的 cl-lib,但如果它足够旧,你也不会有内置的 GNU ELPA 支持,所以所有总之,您最好将 Emacs 升级到 24.3 或更新版本。
如果您的 Emacs 是 24,1 或 24.2,那么我建议您通过 M-x package-install RET
安装 cl-lib,然后添加
(package-initialize)
在你的 ~/.emacs
的开头,它将正确地为你通过 package.el 安装的那些包设置自动加载(例如上面的 cl-lib)。
以 (if (require 'cl-lib ...) ...)
开头的块看起来像是一个丑陋的 hack,用于解决您误解的问题。删除它即可。
此外,从您的 site-lisp
中删除 flymake.el
和 desktop.el
,Emacs 附带的版本可能是最新的。
当我加载 emacs 时,在添加 cl-lib.el:
后使用 --debug-init 时出现此错误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 "52
这是我正在使用的 gv.el 文件:
https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/gv.el
有人有什么建议吗? TIA.
更新:
这是我得到的原始错误:
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 "52
这是我的 .emacs 文件:
(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
(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)
;;
(defun describe-last-function()
(interactive)
(describe-function last-command))
;; get path of present buffer, see
(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)
更新 2:
感谢您的出色 post,@Thomas。这就是我将 .emacs 文件的开头更新为:
;; 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"))
现在这是我得到的错误:
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 "52
抱歉,我是 LISP 新手。
错误源于 Emacs 无法加载正确的文件。您正在尝试在此处手动加载一堆单个文件。但是,这不是应该加载底层包的方式。
通常,软件包附带安装说明,通常需要您在 init 文件中添加一些行:修改加载路径,设置 when 加载软件包的条件,并添加命令 how 来加载包。这些几乎从来没有涉及直接调用非常低级的 load
函数。
如果您查看原始错误,堆栈跟踪会告诉您它是由 (require cl-lib)
抛出的。 require
是 Emacs 在必要时加载文件的机制之一。要使其正常工作,您不需要直接加载相关文件。您所要做的就是设置您的加载路径,以便 Emacs 可以找到所引用的文件。
例如,对于您的 cl-lib.el
文件,您可以这样做:
(add-to-list 'load-path "D:/Tools/Emacs-24.3/cl-lib")
您将此行添加到您的 init 文件中(当然在 Emacs 尝试加载 cl-lib 之前的某个点。
require
的对应部分是 provide
。如果您查看 gv.el
的源代码并一直滚动到底部,您会发现最后一行:
(provide 'gv)
这意味着他的文件提供了 "feature" gv
,并且每当您编写 (require 'gv)
时,您就是在告诉 Emacs 您需要该功能。如果 Emacs 已经知道它,那么一切都很好而且花花公子;如果没有,Emacs 将尝试加载该功能。因此,要加载 gv.el
文件的内容,您所要做的就是将以下内容添加到您的初始化文件中:
(add-to-list 'load-path "/path/to/directory/containing/gv.el")
(require 'gv)
有关 require
和 provide
的更多信息,请参阅 Emacs Manual。
但让我重申上面的一点:通常,软件包附带特定的安装说明,通常 "hidden" 在源代码文件顶部的长注释部分中。因此,无论何时您要手动将包添加到您的设置中,请务必检查此类说明。
旁注:
(mapc 'load <something>)
只有在 <something>
扩展为 文件列表 时才真正有意义。如果像您的情况一样,<something>
只是一个文件,您不妨只写:
(load <something>)
但是,load
是一个低级功能,您作为最终用户几乎不需要。
你的 cl-lib 代码看起来很奇怪。如果您的 Emacs ≥ 24.3,那么您已经内置了 cl-lib。如果你有旧的东西,那么你不能使用 Emacs-24.3 的 cl-lib(你必须使用 GNU ELPA 的 cl-lib,但如果它足够旧,你也不会有内置的 GNU ELPA 支持,所以所有总之,您最好将 Emacs 升级到 24.3 或更新版本。
如果您的 Emacs 是 24,1 或 24.2,那么我建议您通过 M-x package-install RET
安装 cl-lib,然后添加
(package-initialize)
在你的 ~/.emacs
的开头,它将正确地为你通过 package.el 安装的那些包设置自动加载(例如上面的 cl-lib)。
以 (if (require 'cl-lib ...) ...)
开头的块看起来像是一个丑陋的 hack,用于解决您误解的问题。删除它即可。
此外,从您的 site-lisp
中删除 flymake.el
和 desktop.el
,Emacs 附带的版本可能是最新的。