1

I am using the following function workbench. How may I resolve the error

if: Wrong type argument: sequencep, 1

when calling M-x workbench?

With backtrace I get

Debugger entered--Lisp error: (wrong-type-argument sequencep 1)
  concat("~/wb/" "2022-06-29-T13:51:06--" "Arktika" "-" 1 ".org")
  (if name (concat workbench-dtrek (format-time-string "%Y-%m-%d-T%H:%M:%S--") workbench-prefix "-" name ".org") (concat workbench-dtrek (format-time-string "%Y-%m-%d-T%H:%M:%S--") workbench-prefix ".org"))
  (let* ((wbfrmt (concat "*" workbench-prefix "%s%s*")) (buffer (if name (format wbfrmt "-" name) (format wbfrmt "" ""))) (file-name (if name (concat workbench-dtrek (format-time-string "%Y-%m-%d-T%H:%M:%S--") workbench-prefix "-" name ".org") (concat workbench-dtrek (format-time-string "%Y-%m-%d-T%H:%M:%S--") workbench-prefix ".org")))) (switch-to-buffer (generate-new-buffer buffer)) (setq buffer-file-name file-name) (if current-prefix-arg (let* ((mode (completing-read " Langmode [progr,markup]: " (map-keys workbench-modes) nil t nil 'workbench-histr))) (funcall (intern mode))) (funcall (intern (or mode "org-mode")))) buffer-file-name)
  workbench(1)
  funcall-interactively(workbench 1)
  call-interactively(workbench record nil)
  command-execute(workbench record)
  execute-extended-command(nil "workbench" "ark")
  funcall-interactively(execute-extended-command nil "workbench" "ark")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Looks as the problem relates to the condition (if name

(defvar workbench-prefix "Arktika")

(defvar workbench-dtrek "~/wb/")

(defvar workbench-histr nil)

(defvar workbench-modes
  '( ("emacs-lisp-mode" . "el")
     ("lisp-mode" . "lisp")
     ("org-mode" . "org")
     ("f90-mode" . "f90")
     ("c-mode" . "c")
     ("c++-mode" . "cpp")
     ("sh-script" . "sh") ))

(defun workbench (&optional name mode)
  "Generate new temporary buffer."
  (interactive "p")

  (let* ( (wbfrmt
             (concat "*" workbench-prefix "%s%s*"))
          (buffer
             (if name (format wbfrmt "-" name) (format wbfrmt "" "")))
          (file-name
             (if name
                 (concat workbench-dtrek
                         (format-time-string "%Y-%m-%d-T%H:%M:%S--")
                          workbench-prefix "-" name ".org")
               (concat workbench-dtrek
                       (format-time-string "%Y-%m-%d-T%H:%M:%S--")
                       workbench-prefix ".org"))) )

    (switch-to-buffer (generate-new-buffer buffer))
    (setq buffer-file-name file-name)

    (if current-prefix-arg
        (let* ( (mode (completing-read " Langmode [progr,markup]: "
                        (map-keys workbench-modes) nil t nil
                        'workbench-histr)) )
          (funcall (intern mode)))

      (funcall (intern (or mode "org-mode"))))

    buffer-file-name))
1
  • M-x set-variable debug-on-error t Show the backtrace, if it doesn't make clear to you what the problem is.
    – Drew
    Commented Jun 29, 2022 at 1:13

1 Answer 1

1

Emacs is telling you everything you need to know:

  • (wrong-type-argument sequencep 1): emacs is telling you that it got the number 1 when it was expecting a sequence (something like a list or string)
  • concat("~/wb/" "2022-06-29-T13:51:06--" "Arktika" "-" 1 ".org") shows what was executing when that happened and the error is clear: you are trying to concatenate a raw number as though it was a string.

Now look at the code and see 1 must be the value of the argument name. This is an artifact of your interactive form. Is this really what you want? If so, replace name by (number-to-string name).

5
  • No, I do not wish to have a 1. I was expecting to get a nilo r an empty value when no argument is passed, using (if name to either use name in the filename or skip it.
    – Dilna
    Commented Jun 29, 2022 at 10:35
  • It is because (interactive "p") uses the numeric prefix argument.
    – Dilna
    Commented Jun 29, 2022 at 10:45
  • What should I use to solve this problem, and be able to get the name included in file-name?
    – Dilna
    Commented Jun 29, 2022 at 10:48
  • Don't try and harvest the name arg with interactive: just do a read-string similar to what you do with the mode arg. More general advice: it is way more fun to experiment and try things out in the scratch buffer than ask this forum all the time. Commented Jun 29, 2022 at 13:24
  • It is fun but am finding interactive features hard.
    – Dilna
    Commented Jun 29, 2022 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.