【已解决】telega 安装报错 rx wrong-number-of-arguments

  • telega-20210813.1616
  • GNU Emacs 28.0.50

package-install telega 会有好些诸如telega-chat.el:41:1: Error: Wrong number of arguments: (1 . 2), 3 的报错

我调查了一下,发现是在运行以下代码时,产生了问题:

(rx string-start
      (? (group "http" (? "s") "://"))
      (or "t.me" "telegram.me" "telegram.dog")
      (group "/" (1+ (regexp "[^?]")))  ;path
      (? "?" (group (1+ any))))

求解,是因为我用的 Emacs 版本的原因吗?(换用 GNU 官方 ftp 的 27 版,也还是有同样的问题,最新的 master 则是另外的报错 —— 可能的话我也不太想升级,现在这个用着还算稳定)

Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 3)
  regexp-opt(("t.me" "telegram.me" "telegram.dog") nil t)
  rx--translate-or(("t.me" "telegram.me" "telegram.dog"))
  rx--translate-form((or "t.me" "telegram.me" "telegram.dog"))
  rx--translate((or "t.me" "telegram.me" "telegram.dog"))
  mapcar(rx--translate (string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))
  rx--translate-seq((string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))
  rx--translate-form((seq string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))
  rx--translate((seq string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))
  rx--to-expr((seq string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))
  #f(compiled-function (&rest rest) "Translate regular expressions REGEXPS in sexp form to a regexp string.\nEach argument is one of the forms below; RX is a subform, and RX... stands\nfor zero or more RXs.  For details, see Info node `(elisp) Rx Notation'.\nSee `rx-to-string' for the corresponding function.\n\nSTRING         Match a literal string.\nCHAR           Match a literal character.\n\n(seq RX...)    Match the RXs in sequence.  Alias: :, sequence, and.\n(or RX...)     Match one of the RXs.  Alias: |.\n\n(zero-or-more RX...) Match RXs zero or more times.  Alias: 0+.\n(one-or-more RX...)  Match RXs one or more times.  Alias: 1+.\n(zero-or-one RX...)  Match RXs or the empty string.  Alias: opt, optional.\n(* RX...)       Match RXs zero or more times; greedy.\n(+ RX...)       Match RXs one or more times; greedy.\n(? RX...)       Match RXs or the empty string; greedy.\n(*? RX...)      Match RXs zero or more times; non-greedy.\n(+? RX...)      Match RXs one or more times; non-greedy.\n(?? RX...)      Match RXs or the empty string; non-greedy.\n(= N RX...)     Match RXs exactly N times.\n(>= N RX...)    Match RXs N or more times.\n(** N M RX...)  Match RXs N to M times.  Alias: repeat.\n(minimal-match RX)  Match RX, with zero-or-more, one-or-more, zero-or-one\n                and aliases using non-greedy matching.\n(maximal-match RX)  Match RX, with zero-or-more, one-or-more, zero-or-one\n                and aliases using greedy matching, which is the default.\n\n(any SET...)    Match a character from one of the SETs.  Each SET is a\n                character, a string, a range as string \"A-Z\" or cons\n                (?A . ?Z), or a character class (see below).  Alias: in, char.\n(not CHARSPEC)  Match one character not matched by CHARSPEC.  CHARSPEC\n                can be (any ...), (syntax ...), (category ...),\n                or a character class.\nnot-newline     Match any character except a newline.  Alias: nonl.\nanychar         Match any character.  Alias: anything.\nunmatchable     Never match anything at all.\n\nCHARCLASS       Match a character from a character class.  One of:\n alpha, alphabetic, letter   Alphabetic characters (defined by Unicode).\n alnum, alphanumeric         Alphabetic or decimal digit chars (Unicode).\n digit numeric, num          0-9.\n xdigit, hex-digit, hex      0-9, A-F, a-f.\n cntrl, control              ASCII codes 0-31.\n blank                       Horizontal whitespace (Unicode).\n space, whitespace, white    Chars with whitespace syntax.\n lower, lower-case           Lower-case chars, from current case table.\n upper, upper-case           Upper-case chars, from current case table.\n graph, graphic              Graphic characters (Unicode).\n print, printing             Whitespace or graphic (Unicode).\n punct, punctuation          Not control, space, letter or digit (ASCII);\n                              not word syntax (non-ASCII).\n word, wordchar              Characters with word syntax.\n ascii                       ASCII characters (codes 0-127).\n nonascii                    Non-ASCII characters (but not raw bytes).\n\n(syntax SYNTAX)  Match a character with syntax SYNTAX, being one of:\n  whitespace, punctuation, word, symbol, open-parenthesis,\n  close-parenthesis, expression-prefix, string-quote,\n  paired-delimiter, escape, character-quote, comment-start,\n  comment-end, string-delimiter, comment-delimiter\n\n(category CAT)   Match a character in category CAT, being one of:\n  space-for-indent, base, consonant, base-vowel,\n  upper-diacritical-mark, lower-diacritical-mark, tone-mark, symbol,\n  digit, vowel-modifying-diacritical-mark, vowel-sign,\n  semivowel-lower, not-at-end-of-line, not-at-beginning-of-line,\n  alpha-numeric-two-byte, chinese-two-byte, greek-two-byte,\n  japanese-hiragana-two-byte, indian-two-byte,\n  japanese-katakana-two-byte, strong-left-to-right,\n  korean-hangul-two-byte, strong-right-to-left, cyrillic-two-byte,\n  combining-diacritic, ascii, arabic, chinese, ethiopic, greek,\n  korean, indian, japanese, japanese-katakana, latin, lao,\n  tibetan, japanese-roman, thai, vietnamese, hebrew, cyrillic,\n  can-break\n\nZero-width assertions: these all match the empty string in specific places.\n line-start         At the beginning of a line.  Alias: bol.\n line-end           At the end of a line.  Alias: eol.\n string-start       At the start of the string or buffer.\n                     Alias: buffer-start, bos, bot.\n string-end         At the end of the string or buffer.\n                     Alias: buffer-end, eos, eot.\n point              At point.\n word-start         At the beginning of a word.  Alias: bow.\n word-end           At the end of a word.  Alias: eow.\n word-boundary      At the beginning or end of a word.\n not-word-boundary  Not at the beginning or end of a word.\n symbol-start       At the beginning of a symbol.\n symbol-end         At the end of a symbol.\n\n(group RX...)  Match RXs and define a capture group.  Alias: submatch.\n(group-n N RX...) Match RXs and define capture group N.  Alias: submatch-n.\n(backref N)    Match the text that capture group N matched.\n\n(literal EXPR) Match the literal string from evaluating EXPR at run time.\n(regexp EXPR)  Match the string regexp from evaluating EXPR at run time.\n(eval EXPR)    Match the rx sexp from evaluating EXPR at compile time.\n\nAdditional constructs can be defined using `rx-define' and `rx-let',\nwhich see." #<bytecode -0x734bda1750fc942>)(string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any))))
  macroexpand((rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))) nil)
  macroexp-macroexpand((rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))) nil)
  macroexp--expand-all((rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))
  macroexp--all-forms((progn (rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any))))) 1)
  #f(compiled-function (form func) #<bytecode 0x285ee96096126bc>)(((progn (rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any)))))) progn)
  macroexp--expand-all((progn (rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any))))))
  macroexpand-all((progn (rx string-start (32 (group "http" (32 "s") "://")) (or "t.me" "telegram.me" "telegram.dog") (group "/" (1+ (regexp "[^?]"))) (32 "?" (group (1+ any))))))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

关键在这一行,regexp-opt 只接受 2 个参数,你这里显示给了 3 个。

describe-function 查看一下你的 rx--translate-or 函数里面的 regexp-opt 到底给了几个参数。

多谢,问题解决了

原来是我的 load-path 里有旧的 lisp 文件,包含了 rx.el,其定义中的 regexp-opt 用了三个参数。修改 load-path 之后就好了。

教训:应该先耐心 emacs -q 试一下的