abo-abo / pamparam

Simple and fast flashcards for Emacs
229 stars 16 forks source link

Error when calling pamparam-sync: Wrong number of arguments: (1 . 1), 2 #11

Closed chip2n closed 6 years ago

chip2n commented 6 years ago

Calling pamparam-sync on the capitals.org example throws an error currently. The issue seems to be the usage of string-trim-right:

https://github.com/abo-abo/pamparam/blob/1eddc9be67ff66cc4a8e4eefc28f891f455df8d9/pamparam.el#L614

It seems that this function only expects a single argument - is the two argument version missing from my system? I'm pretty new to elisp so it's possible I'm just missing something trivial though...

Here's the backtrace for reference:

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 1) 2)
  string-trim-right("Berlin" "\n+")
  (setq back (string-trim-right back "\n+"))
  (cond ((string-match "^\\*+ a\n\\(.*\\)" str) (setq front (substring str 0 (match-beginning 0))) (setq back (concat "* a\n" (match-string 1 str))) (setq front (string-trim-left front "[* ]*")) (goto-char (cdr bnd))) ((string-match "\\`\\*+ \\(.*\\)\n\\([^*]+\\)\\(?:\n\\*\\)?" str) (setq front (match-string 1 str)) (setq back (match-string 2 str)) (goto-char (+ (car bnd) (match-end 2))) (setq back (string-trim-right back "\n+"))) (t (error "unexpected")))
  (let* ((bnd (worf--bounds-subtree)) (str (lispy--string-dwim bnd)) front back) (cond ((string-match "^\\*+ a\n\\(.*\\)" str) (setq front (substring str 0 (match-beginning 0))) (setq back (concat "* a\n" (match-string 1 str))) (setq front (string-trim-left front "[* ]*")) (goto-char (cdr bnd))) ((string-match "\\`\\*+ \\(.*\\)\n\\([^*]+\\)\\(?:\n\\*\\)?" str) (setq front (match-string 1 str)) (setq back (match-string 2 str)) (goto-char (+ (car bnd) (match-end 2))) (setq back (string-trim-right back "\n+"))) (t (error "unexpected"))) (cons front back))
  pamparam--card-info()
  (let* ((card-info (pamparam--card-info)) (card-front (car card-info)) (card-body (cdr card-info)) card-info card-file) (if (member card-front processed-headings) (error "Duplicate heading encountered: %s" card-front) (setq processed-headings (cons card-front processed-headings))) (if (setq card-info (pamparam-update-card card-front card-body repo-dir)) (progn (setq card-file (file-name-nondirectory (cdr card-info))) (cond ((eq (car card-info) (quote new)) (setq new-cards (cons card-file new-cards))) ((eq (car card-info) (quote update)) (setq updated-cards (cons card-file updated-cards)))))))
  (while (re-search-forward "^\\*\\{2,3\\} \\(.*\\)$" end t) (let* ((card-info (pamparam--card-info)) (card-front (car card-info)) (card-body (cdr card-info)) card-info card-file) (if (member card-front processed-headings) (error "Duplicate heading encountered: %s" card-front) (setq processed-headings (cons card-front processed-headings))) (if (setq card-info (pamparam-update-card card-front card-body repo-dir)) (progn (setq card-file (file-name-nondirectory (cdr card-info))) (cond ((eq (car card-info) (quote new)) (setq new-cards (cons card-file new-cards))) ((eq (car card-info) (quote update)) (setq updated-cards (cons card-file updated-cards))))))))
  (let ((end (save-excursion (outline-end-of-subtree) (point)))) (while (re-search-forward "^\\*\\{2,3\\} \\(.*\\)$" end t) (let* ((card-info (pamparam--card-info)) (card-front (car card-info)) (card-body (cdr card-info)) card-info card-file) (if (member card-front processed-headings) (error "Duplicate heading encountered: %s" card-front) (setq processed-headings (cons card-front processed-headings))) (if (setq card-info (pamparam-update-card card-front card-body repo-dir)) (progn (setq card-file (file-name-nondirectory (cdr card-info))) (cond ((eq ... ...) (setq new-cards ...)) ((eq ... ...) (setq updated-cards ...))))))) (list processed-headings new-cards updated-cards))
  pamparam-sync-current-outline(nil nil nil "/home/chip/pamparam/doc/sets/capitals/capitals.pam")
  (setq --cl-rest-- (pamparam-sync-current-outline processed-headings new-cards updated-cards repo-dir))
  (progn (setq --cl-rest-- (pamparam-sync-current-outline processed-headings new-cards updated-cards repo-dir)) (setq processed-headings (if (= (length --cl-rest--) 3) (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--)))) (signal (quote wrong-number-of-arguments) (list nil (length --cl-rest--))))) (setq new-cards (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--))))) (setq updated-cards (car --cl-rest--)))
  (with-no-warnings (progn (setq --cl-rest-- (pamparam-sync-current-outline processed-headings new-cards updated-cards repo-dir)) (setq processed-headings (if (= (length --cl-rest--) 3) (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--)))) (signal (quote wrong-number-of-arguments) (list nil (length --cl-rest--))))) (setq new-cards (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--))))) (setq updated-cards (car --cl-rest--))))
  (while (re-search-forward pamparam-card-source-regexp nil t) (with-no-warnings (progn (setq --cl-rest-- (pamparam-sync-current-outline processed-headings new-cards updated-cards repo-dir)) (setq processed-headings (if (= (length --cl-rest--) 3) (car-safe (prog1 --cl-rest-- (setq --cl-rest-- ...))) (signal (quote wrong-number-of-arguments) (list nil (length --cl-rest--))))) (setq new-cards (car-safe (prog1 --cl-rest-- (setq --cl-rest-- (cdr --cl-rest--))))) (setq updated-cards (car --cl-rest--)))))
  (let ((old-point (point)) (processed-headings nil) (new-cards nil) (updated-cards nil)) (goto-char (point-min)) (if (re-search-forward pamparam-card-source-regexp nil t) nil (error "No outlines with the :cards: tag found")) (beginning-of-line) (while (re-search-forward pamparam-card-source-regexp nil t) (with-no-warnings (progn (setq --cl-rest-- (pamparam-sync-current-outline processed-headings new-cards updated-cards repo-dir)) (setq processed-headings (if (= (length --cl-rest--) 3) (car-safe (prog1 --cl-rest-- ...)) (signal (quote wrong-number-of-arguments) (list nil ...)))) (setq new-cards (car-safe (prog1 --cl-rest-- (setq --cl-rest-- ...)))) (setq updated-cards (car --cl-rest--))))) (goto-char old-point) (if (or new-cards updated-cards) (progn (pamparam-schedule-today (mapcar (function pamparam--todo-from-file) new-cards) (find-file (expand-file-name "pampile.org" repo-dir))) (shell-command-to-string (format "cd %s && git add . && git commit -m %s" (shell-quote-argument repo-dir) (shell-quote-argument (cond (... ...) (... ...) (t ...))))))) (message "%d new cards, %d updated, %d total" (length new-cards) (length updated-cards) (length processed-headings)))
  pamparam--sync("/home/chip/pamparam/doc/sets/capitals/capitals.pam")
  (let ((repo-dir (pamparam-repo-directory (buffer-file-name))) (make-backup-files nil)) (pamparam-repo-init repo-dir) (pamparam--recompute-git-cards repo-dir) (pamparam--sync repo-dir))
  pamparam-sync()
  funcall-interactively(pamparam-sync)
  call-interactively(pamparam-sync record nil)
  command-execute(pamparam-sync record)
  helm-M-x(nil #("pamparam-sync" 0 13 (match-part "pamparam-sync")))
  funcall-interactively(helm-M-x nil #("pamparam-sync" 0 13 (match-part "pamparam-sync")))
  call-interactively(helm-M-x nil nil)
  command-execute(helm-M-x)
abo-abo commented 6 years ago

Fixed, thanks. I'm using Emacs26, so I didn't have this problem.

chip2n commented 6 years ago

Thanks! I also believe the same problem exists a couple of lines above it (string-trim-left front "[* ]*") - didn't see that one.

Cool package by the way - I'll be giving it a go for sure!