Inactivate emacs-lisp % format specifier

45 views Asked by At

Using emacs-lisp I want to identify the word under point, specifically I want to be able to identify hoon runes. Runes are digraphs like ?=, /+, $-. Standard emacs lisp functions like 'thing-at-point', 'current-word' work fine for most runes except those beginning with %. % is a special character signifying that a format specifier follows. The previous functions as well as custom functions I have written that identify point and individually examine characters all fail with the error:

format string ends in middle of format specifier

(put 'format 'disabled t) is ineffective

(disable-command format) does not work error: invalid command name 'format'??

Any suggestions? How can I redefine %'s function or set to nil? inactivate %? Catch the error and extract the rune?

1

There are 1 answers

0
Mortimer Cladwell On

Manually scanning characters works:

(defun get-token-definition ()
  (interactive)
  (if (get-buffer "*html*")
      (progn
    (delete-window)
    (kill-buffer "*html*"))    
      (let* ((current-loc (point))
         (before-space (re-search-forward "[ (\n]" nil nil -1))
         (dummy (goto-char current-loc))
         (after-space (re-search-forward "[ (\n]" nil nil 1))
         (aa  (buffer-substring-no-properties  before-space  (- after-space 1) ))
         (def (gethash aa alldefs))) ;;gets the definition from the hash table alldefs      
    (if (eq nil def) 
        (message "%s %s" aa "is not in the dictionary!")
      (prep-foo-buffer def)))))