emacs initialization and updating emacs packages

╄→гoц情女王★ 提交于 2019-12-06 15:20:07

问题


I am violating probably the most essential emacs package rule in my .emacs file by loading a specific path to an emacs (workgroups2) package which gets updated. So, everytime a new version is released and when I upgrade I have to edit my emacs file (this is the first line below).

The following is the relevant section of my emacs file. How can I load this without adding a specific path? Let me know what other suggestions you have and thanks!

To be clear the line we are considering is: (add-to-list 'load-path "~/.emacs.d/elpa/workgroups2-20130915.1509")

(add-to-list 'load-path "~/.emacs.d/elpa/workgroups2-20130915.1509")
(require 'workgroups2)
(setq package-enable-at-startup nil)
(package-initialize)

(desktop-save-mode nil)     ; save all opened files (or disable it)                                                                                                         
(setq wg-prefix-key (kbd "C-c w")
      wg-restore-associated-buffers t ; restore all buffers opened in this WG?                                                                                              
      wg-use-default-session-file t   ; turn off for "emacs --daemon"                                                                                                       
      wg-default-session-file "~/.emacs.d/emacs_def.wg"
      wg-use-faces nil
      wg-morph-on nil)                  ; animation off                                                                                                                     

;; Keyboard shortcuts - load, save, switch                                                                                                                                  
(global-set-key (kbd "<pause>")     'wg-reload-session)
(global-set-key (kbd "C-S-<pause>") 'wg-save-session)
(global-set-key (kbd "s-z")         'wg-switch-to-workgroup)
(global-set-key (kbd "s-/")         'wg-switch-to-previous-workgroup)

(workgroups-mode 1)     ; Activate workgroups 

EDIT: If I comment out that line, this is what the debugger gives me:

Debugger entered--Lisp error: (file-error "Cannot open load file" "workgroups2")
  require(workgroups2)
  eval-buffer(#<buffer  *load*> nil "/home/d2b2/.emacs.d/init.el" nil t)  ; Reading at buffer position 6014
  load-with-code-conversion("/home/d2b2/.emacs.d/init.el" "/home/d2b2/.emacs.d/init.el" t t)
  load("/home/d2b2/.emacs.d/init" t t)
  #[0 "^H\205\262^@     \306=\203^Q^@\307^H\310Q\202;^@ \311=\204^^^@\307^H\312Q\202;^@\313\307\314\315#\203*^@\316\202;^@\313\307\314\317#\203:^@\320\nB^R\321\202;^@\316\$
  command-line()
  normal-top-level()

EDIT: Now commenting out both lines we have the following errors:

Debugger entered--Lisp error: (error ":END: line missing at position 186")
  signal(error (":END: line missing at position 186"))
  error(":END: line missing at position %s" 186)
  org-flag-drawer(t)
  org-cycle-hide-drawers(all)
  org-set-startup-visibility()
  org-mode()
  desktop-restore-file-buffer("/home/d2b2/.todo" ".todo" nil)
  #[nil "^H     \236A\206^H^@\305\n^K\f#\207" [desktop-buffer-major-mode desktop-buffer-mode-handlers desktop-buffer-file-name desktop-buffer-name desktop-buffer-misc deskt$
  desktop-create-buffer(206 "/home/d2b2/.todo" ".todo" org-mode (workgroups-mode) 1 (nil nil) nil nil ((buffer-file-coding-system . undecided-unix) (truncate-lines . t)))
  eval-buffer(#<buffer  *load*> nil "/home/d2b2/.emacs.desktop" nil t)  ; Reading at buffer position 813
  load-with-code-conversion("/home/d2b2/.emacs.desktop" "/home/d2b2/.emacs.desktop" t t)
  load("/home/d2b2/.emacs.desktop" t t t)
  desktop-read()
  #[nil "\304\211^X     \235\203^O^@\305^H      \"^Q\306^R)\n\205^Z^@\307 \210\310\211^S\207" [key command-line-args desktop-save-mode inhibit-startup-screen "--no-desktop"$
  run-hooks(after-init-hook)
  command-line()
  normal-top-level()

回答1:


Make sure, that package-directory-list includes your path to elpa ~/.emacs.d/elpa.

Then package.el initializes some package, it adds name of package to package-activated-list and pushes package directory (e.g. ~/.emacs.d/elpa/workgroups2-20130915.1509) to load-path automatically.

For me it works as usual, I don't add any specific pathes for packages manually. The value of package-enable-at-startup is t in my config.

package-enable-at-startup doc: "Whether to activate installed packages when Emacs starts...If the value of package-enable-at-startup is nil, you can type M-x package-initialize to activate the package system at any time."

(require 'workgroups2) is before package initialization in your config, try to move it below.



来源:https://stackoverflow.com/questions/19482056/emacs-initialization-and-updating-emacs-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!