Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call interactive Emacs Lisp function with a prefix argument, from another Emacs Lisp function?
    primarykey
    data
    text
    <p>I want to write an Emacs Lisp function that will turn on <code>flyspell-mode</code> regardless of the current state of the mode. Function <code>flyspell-mode-on</code> is deprecated. The documentation suggests that a positive prefix argument will turn <code>flyspell-mode</code>, but unfortunately running</p> <pre><code>(flyspell-mode 1) </code></pre> <p>results in an error message:</p> <pre><code>Wrong number of arguments: (lambda (flyspell-mode 1)), 0 </code></pre> <p>If I could figure out how to call <code>flyspell-mode</code> with a <em>prefix</em> argument, I believe I could solve this problem.</p> <p>The most relevant section I can find in the Emacs Lisp manual is the section entitled "Interactive Call", which describes such commands as <code>call-interactively</code>. This is emphatically not what I want.</p> <p>(The ultimate problem I am trying to solve is to create a mode hook that turns on the mode regardless of its current state.)</p> <p>N.B. The title of the question <a href="https://stackoverflow.com/questions/6156286/">emacs lisp call function with prefix argument programmatically</a> makes it appear to be related, but that question was asking about how to create an interactive command, and the issue was ultimately resolved by using <code>call-interactively</code>.</p> <hr> <p><strong>EDIT</strong>: This question is moot; I have found an alternate solution to my original problem:</p> <pre><code>(add-hook 'text-mode-hook (function (lambda () (require 'flyspell) (if flyspell-mode nil (flyspell-mode))))) </code></pre> <p>But I would still like to know how to call an Emacs Lisp function with a prefix argument, from another Emacs Lisp function, with <em>nothing</em> interactive.</p> <hr> <p><strong>UPDATE</strong>: Perhaps I should have asked why I was getting that error message...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload