1
votes

Tried to use the persp-mode https://github.com/Bad-ptr/persp-mode.el/blob/master/persp-mode.el to retrieve the emacs windows session after restart. Unable to get it working.

So trying to understand the datastructure used to store the state of the emacs by reading the source code.

The following is the function which is used to store the session state.

(defun* persp-save-state-to-file (&optional (fname persp-auto-save-fname)
                                            (phash *persp-hash*)
                                            respect-persp-file-parameter)
  (interactive (list (read-file-name "Save perspectives to file: "
                                     persp-save-dir)))

In the above function two unusual things are observed using edebug (unusual according to my current understanding of elisp).

  1. The optional argument expressions are evaluated.

  2. The expression "(interactive..." is evaluated first and then the optional argument expressions are evaluated.

Any ideas how to debug the code. Also the emacs documentation says "defun*" is related to common-lisp, but no further information is available in emacs docs on how defun* is different from defun. Is there a quick tutorial oh what defun* does without having to learn common-lisp.

2
> Unable to get it working. | And what's wrong and doesn't work? Any error messages?Bad_ptr
@Bad_ptr: Finally got it to working. Not found the exact cause of the error. But it has something to do with elc files. Persp-mode depends on "workspace" mode and i tried to use the "wg-save" and "wg-load" command from the workspace package and it was not working. But using (load-file) on the workspace.el file worked. So after deleting the workspace.el file everything works fine.Talespin_Kit

2 Answers

3
votes

Emacs says:

Define NAME as a function. Like normal `defun', except ARGLIST allows full Common Lisp conventions, and BODY is implicitly surrounded by (cl-block NAME ...).

Common Lisp arglists provide optional, rest, keyword and aux arguments. Historically this comes from Lisp Machine Lisp and Mumble - two earlier Lisp dialects.

For details see: http://www.gnu.org/software/emacs/manual/html_node/cl/Argument-Lists.html

1
votes

Have a look at this post for a simplistic snippet explaining how optional works. The gist is that e.g. persp-auto-save-fname will be the value of fname if none is given.

And obviously interactive has to be run first, because it provides the arguments. So if interactive doesn't provide a value for fname it will be persp-auto-save-fname.