Issue
Invoking mediawiki-open with cursor NOT between "[[" and "]]" produces
byte-code: Wrong type argument: integer-or-marker-p, nil
WA: (load "boe-mw") with boe-mw.el as below. -- Tested in .emacs after byte-compiling.
Note: Invoking mediawiki-open with cursor between "[[" and "]]" works as expected
boe-mw.el
;;; -*- lexical-binding: t; -*-
(defun mediawiki-drop-from-pipe (s)
"Return page target, dropping chars from pipe to end
Seems OK also for File: links with attributes"
(let ((pipepos (seq-position s ?|)))
(if pipepos
(substring s 0 pipepos)
s)))
(defun mediawiki-page-at-point ()
"Return the page name under point.
Typically, this means anything enclosed in [[PAGE]]."
(let ((pos (point))
(eol (pos-eol))
(bol (pos-bol)))
(save-excursion
(let* ((start (when (search-backward "[[" bol t)
(+ (point) 2)))
(end (when (search-forward "]]" eol t)
(- (point) 2)))
(pagename (mediawiki-drop-from-pipe
(when (and
(not (eq nil start))
(not (eq nil end))
(<= pos end)
(>= pos start))
(buffer-substring-no-properties
start end)))))
(if (and pagename (string= "/"
(substring pagename 0 1)))
(concat mediawiki-page-title pagename))
pagename))))
(defun mediawiki-open (name)
"Open a wiki page specified by NAME from the mediawiki engine."
(interactive
(let* ((hist (cdr (assoc-string mediawiki-site mediawiki-page-history)))
(temp-history-symbol (make-symbol "mediawiki-temp-history")))
(set temp-history-symbol hist)
(list (read-string "Wiki Page: " (mediawiki-page-at-point) temp-history-symbol))))
(when (or (not (stringp name))
(string-equal "" name))
(error "Need to specify a name"))
(mediawiki-edit mediawiki-site name))
Issue
Invoking
mediawiki-openwith cursor NOT between "[[" and "]]" producesbyte-code: Wrong type argument: integer-or-marker-p, nilWA:
(load "boe-mw")with boe-mw.el as below. -- Tested in .emacs after byte-compiling.Note: Invoking mediawiki-open with cursor between "[[" and "]]" works as expected
boe-mw.el