anchor.diff:         (shift-position (- (length str)))
          (search-forward str))
      #'search-forward
  -   #'search-backward))
  +   #'search-backward
  +   ""))
   
   (define-key *global-keymap* (kbd "C-r") 'isearch-backward)
   (define-command isearch-backward () ()
  
positive.code: (in-package :cl-user)
  (defpackage :lem.isearch
    (:use :cl :lem))
  (in-package :lem.isearch)
  
  (export '(*isearch-keymap*
            isearch-mode
            isearch-forward
            isearch-backward
            isearch-forward-regexp
            isearch-backward-regexp
            isearch-forward-symbol
            isearch-backward-symbol
            isearch-abort
            isearch-delete-char
            isearch-raw-insert
            isearch-end
            isearch-next
            isearch-prev
            isearch-yank
            isearch-self-insert
            query-replace
            query-replace-regexp
            query-replace-symbol))
  
  (defvar *isearch-keymap* (make-keymap 'isearch-self-insert))
  (defvar *isearch-prompt*)
  
negative.code:        (shift-position (length str))
         (search-backward str))
     #'search-forward
     #'search-backward
     ""))
  
  (define-key *global-keymap* (kbd "C-M-s") 'isearch-forward-regexp)
  (define-command isearch-forward-regexp () ()
    (isearch-start "ISearch Regexp: "
                   #'search-forward-regexp
                   #'search-forward-regexp
                   #'search-backward-regexp
                   ""))
  
  (define-key *global-keymap* (kbd "C-M-r") 'isearch-backward-regexp)
  (define-command isearch-backward-regexp () ()
    (isearch-start "ISearch Regexp: "
                   #'search-backward-regexp
                   #'search-forward-regexp
                   #'search-backward-regexp
                   ""))
  
  (define-key *global-keymap* (kbd "C-x C-M-s") 'isearch-forward-symbol)
  (define-command isearch-forward-symbol () ()
    (isearch-start "ISearch Symbol: "
                   #'search-forward-symbol
                   #'search-forward-symbol
                   #'search-backward-symbol
                   ""))
  
  (define-key *global-keymap* (kbd "C-x C-M-r") 'isearch-backward-symbol)
  (define-command isearch-backward-symbol () ()
    (isearch-start "ISearch Symbol: "
                   #'search-backward-symbol
                   #'search-forward-symbol
                   #'search-backward-symbol
                   ""))
  
  (define-key *global-keymap* (kbd "C-x .") 'isearch-forward-symbol-at-point)
  (define-command isearch-forward-symbol-at-point () ()
    (skip-chars-forward #'syntax-symbol-char-p)
    (skip-chars-backward #'syntax-symbol-char-p t)
    (skip-chars-backward #'syntax-symbol-char-p)
    (let ((start (current-point)))
      (skip-chars-forward #'syntax-symbol-char-p)
      (let ((end (current-point)))
        (isearch-start "ISearch Symbol: "
                       #'search-forward-symbol
                       #'search-forward-symbol
                       #'search-backward-symbol
                       (region-string start end)))))
  
  (defun isearch-start (prompt
                        search-func
                        search-forward-function
                        search-backward-function
                        initial-string)
    (isearch-mode t)
    (setq *isearch-prompt* prompt)
    (setq *isearch-string* initial-string)
    (setq *isearch-search-function* search-func)
    (setq *isearch-start-point* (current-point))
    (setq *isearch-search-forward-function* search-forward-function)
    (setq *isearch-search-backward-function* search-backward-function)
    (isearch-update-display)
    t)
  
  (define-key *isearch-keymap* (kbd "C-g") 'isearch-abort)
  