Вопрос

I'm having issues with setting markdown-command. I get symbol as a variable is void. I originally was setting inside of customize and had everything working. I wanted to clean up my init.el and I would rather keep everything outside of customize and set it manually.

Can anyone provide insight to this? Closest thing i have seen was here:https://stackoverflow.com/questions/12058717/confusing-about-the-emacs-custom-system

Thanks.

    ;;General Settings
    (global-auto-revert-mode t) ;;Refresh Buffers on File Change.
    (setq-default indent-tabs-mode nil) ;;Use spaces instead of tabs.
    (desktop-save-mode 1) ;;Save session
    (show-paren-mode 1) ;;Show matching parenthesis

    ;;Custom Load Paths
    (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") ;;Look here for additional themes.
    (add-to-list 'load-path "~/.emacs.d/modes/") ;;Look here for additional modes.


    ;;Load Specific Them
    (load-theme 'solarized-dark t)

    ;;Marmalade Package Manager
    (require 'package)
    (add-to-list 'package-archives 
        '("marmalade" .
          "http://marmalade-repo.org/packages/"))
    (package-initialize)

    ;;OSX Specific Settings
    ;;Add /usr/local/bin and /opt/local/bin to execution path
    (if (eq system-type 'darwin)
        (setq exec-path
              (append 
               '("/usr/local/bin"
                 "/opt/local/bin")
               exec-path)))


    ;;Markdown Specific Settings
    (autoload 'markdown-mode "markdown-mode"
       "Major mode for editing Markdown files" t)
    (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
    (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
    (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
     (if (eq system-type 'darwin)
        (setq-default 'markdown-command '("/usr/local/bin/pandoc"))
       (setq-default 'markdown-command '("/usr/bin/multimarkdown")))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
)

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

As per suggestion I tried

 (eval-after-load "markdown-mode"
 (if (eq system-type 'darwin)
 (setq markdown-command '("/usr/local/bin/pandoc"))
 (setq markdown-command '("/usr/bin/multimarkdown"))))

Then I realized my mistake. I hadn't done what was suggested.

    (eval-after-load "markdown-mode"
    (if (eq system-type 'darwin)
    '(setq markdown-command ("/usr/local/bin/pandoc"))
   '(setq markdown-command ("/usr/bin/multimarkdown"))))

Also as mentioned eval-after-load "markdown-mode" is not needed.

Это было полезно?

Решение 3

This is not a great idea, in general:

I originally was setting inside of customize and had everything working. I wanted to clean up my init.el and I would rather keep everything outside of customize and set it manually.

Yes, keep Customize out of your init file. But that does not mean that you need to abandon use of Customize. Use it for what it's good for. And confine it to its own file, by defining option custom-file.

For your current problem, you do not need eval-after-load or any of the other code, to define this option the way you want it. You simply need to do M-x customize-option RET markdown-command RET and save the value after you update it --- in Customize.

This is the right way to customize user options.

Другие советы

The code is failing because variable markdown-command is defined in markdown-mode and markdown-mode is not loaded yet. You can arrange for the variable to be set whenever markdown-mode is loaded by adding this to your init file.

(eval-after-load "markdown-mode"
  '(setq markdown-command '("/usr/bin/markdown")))

From C-hfeval-after-loadRET

Arrange that if FILE is loaded, FORM will be run immediately afterwards.
If FILE is already loaded, evaluate FORM right now.

UPDATE

If you only wish to keep the customize options out of your init file you can add the following to your init file

(setq custom-file "~/your-custom-file")
(load custom-file)

The algorithm to save your settings is like this: if the variable is customizable (look for the You can customize this variable. line at the bottom of the *Help* buffer for the variable), you put

(custom-set-variables
 '(markdown-command '("/usr/local/bin/pandoc"))
 '(indent-tabs-mode nil))

into your .emacs, otherwise you use setq.

When the package which uses your customization is actually loaded, it will set the variable correctly based on your custom-set-variables calls.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top