LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   emacs cannot launch a function from the commandline (https://www.linuxquestions.org/questions/linux-software-2/emacs-cannot-launch-a-function-from-the-commandline-756254/)

jgombos 09-18-2009 03:17 PM

emacs cannot launch a function from the commandline
 
I want to launch emacs and have it immediately launch into pwsafe-mode.

My .emacs file properly loads the pwsafe.el file, so everything works when invoking M-x pwsafe. But when I run this on the CLI:

emacs -f pwsafe

the output message is indicates a missing argument:
Code:

command-line-1: Wrong number of arguments: (lambda (force) "Major mode to interact with the command line password safe pwsafe.
Queries the passwords from the password safe and displays them in the buffer *pwsafe-list*.
The following keys are defined:
\\{pwsafe-list-mode-map}" (interactive "P") (if (and (not force) (not (string= (buffer-name) "*pwsafe-list*")) (get-buffer "*pwsafe-list*")) (pop-to-buffer "*pwsafe-list*") (let ((database-file-name (pwsafe-current-database-name))) (if (file-exists-p database-file-name) (if pwsafe-use-long-listing (pwsafe-run (quote list) "-l" "-f" database-file-name) (pwsafe-run (quote list) "-f" database-file-name)) (when (yes-or-no-p (format "pwsafe database %s does not exist - create it? " database-file-name)) (pwsafe-createdb) (with-current-buffer (get-buffer "*pwsafe*") (delete-region (point-min) (point-max))) (pwsafe-list-passwords)))))), 0
mouse-minibuffer-check: Minibuffer window is not active [2 times]

Any ideas how to fix or workaround?

gsan70 09-19-2009 12:21 PM

You can set a default mode in emacs. Add the following line in your .emacs file,

(setq default-major-mode 'pwsafe-mode)

jgombos 09-19-2009 12:46 PM

Quote:

Originally Posted by gsan70 (Post 3689816)
You can set a default mode in emacs. Add the following line in your .emacs file,

(setq default-major-mode 'pwsafe-mode)

Thanks for the suggestion, but it was the same problem. Apparently there is no CLI or configuration equivalent to typing M-x pwsafe.

I've extracted the relevant code that executes:
Code:

;;;###autoload
(defun pwsafe (force)
  "Major mode to interact with the command line password safe pwsafe.
Queries the passwords from the password safe and displays them in the buffer *pwsafe-list*.
The following keys are defined:
\\{pwsafe-list-mode-map}"
  (interactive "P")
  (if (and (not force)
          (not (string= (buffer-name) "*pwsafe-list*"))
          (get-buffer "*pwsafe-list*"))
      (pop-to-buffer "*pwsafe-list*")
...

So there really is an argument, which apparently is not needed when running interactively. So the question is, how can I pass "nil" or "t" or something to a function that is run on the CLI?

[EDIT] Got my solution:
Code:

emacs --eval='(pwsafe nil)'


All times are GMT -5. The time now is 02:24 AM.