From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Buchs, Kevin J." Newsgroups: gmane.emacs.help Subject: updating buffer window while accepting minibuffer input Date: Wed, 16 Jul 2014 16:12:57 -0500 Message-ID: <9025b1$hrbs0b@ironport9.mayo.edu> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1405545211 4019 80.91.229.3 (16 Jul 2014 21:13:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Jul 2014 21:13:31 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 16 23:13:27 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X7WVy-0002yb-FY for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Jul 2014 23:13:26 +0200 Original-Received: from localhost ([::1]:41302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7WVx-0006fL-Gd for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Jul 2014 17:13:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7WVg-0006eC-V6 for help-gnu-emacs@gnu.org; Wed, 16 Jul 2014 17:13:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7WVb-0002kz-NR for help-gnu-emacs@gnu.org; Wed, 16 Jul 2014 17:13:08 -0400 Original-Received: from mail9.mayo.edu ([129.176.114.197]:64339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7WVb-0002kR-G6 for help-gnu-emacs@gnu.org; Wed, 16 Jul 2014 17:13:03 -0400 Original-Received: from unknown (HELO mail9.mayo.edu) ([10.146.65.140]) by ironport9-poly.mayo.edu with ESMTP; 16 Jul 2014 16:13:01 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqcEAHTqxlMKgNEM/2dsb2JhbABWA4NgV8MsBodGAYEfdoQEAQU4BAFKAhg5GzYGEwgBAYhDxBqGRRuPThGCJQ9ABIE6BYRwhXSJIIhlhXGGVol7Tg Original-Received: from unknown (HELO msgoms03.mayo.edu) ([10.128.209.12]) by ironport9.mayo.edu with ESMTP; 16 Jul 2014 16:13:00 -0500 In-reply-to: User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 129.176.114.197 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98695 Archived-At: This is a follow-up to "regexp nirvana - near miss" (thanks Drew for giving me this programming burden ;-). I'm wanting to traverse a list of buffer positions according to minibuffer keystrokes and have the referenced buffer position update (and eventually highlight) much like isearch-*. I'm stuck on the buffer position not actually updating whilest I am in the midst of (read-minibuffer-input). I have spent about two hours delving into how isearch works and came out without a clue as to how it actually gets minibuffer reading activated. So, I'm seeking help. Code follows signature. Kevin Buchs Research Computer Services Phone: 507-538-5459 Mayo Clinic 200 1st. St SW Rochester, MN 55905 http://mayoclinic.org http://facebook.com/MayoClinic http://youtube.com/MayoClinic http://twitter.com/MayoClinic (defun regexpneg-fwd () (interactive) ;; Move to next match (if (< regexpneg-pointer (1- (length regexpneg-list))) (progn (set-buffer regexpneg-buffer) (setq regexpneg-pointer (1+ regexpneg-pointer)) (goto-char (nth regexpneg-pointer regexpneg-list)) (recenter 5) (message "buffer: %S, position: %d, pointer: %d" (current-buffer) (point) regexpneg-pointer)))) (defun regexpneg-rev () (interactive) ;; Move to prior match (unless (= regexpneg-pointer 0) (set-buffer regexpneg-buffer) (setq regexpneg-pointer (1- regexpneg-pointer)) (goto-char (nth regexpneg-pointer regexpneg-list)) (recenter 5) (message "buffer: %S, position: %d, pointer: %d" (current-buffer) (point) regexpneg-pointer))) (defun regexpneg (part negpart) "Search for regexp part, not followed by regexp negpart; You can advance in search hits with C-s or SPACE. Reverse with C-r or DEL" (interactive) (let ( (point-start (point)) (subsetnotlist '())) ;; Save a reference to current buffer (setq regexpneg-buffer (current-buffer)) ;; Search for 'part' - return list of locations = regexpneg-list (setq regexpneg-list '()) (while (re-search-forward part nil t) (setq regexpneg-list (append regexpneg-list (list (match-beginning 0))))) ;; Search for 'part'+'negpart' - return list of locations = subsetnotlist (goto-char point-start) (while (re-search-forward (concat part negpart) nil t) (setq subsetnotlist (append subsetnotlist (list (match-beginning 0))))) ;; Delete members of subsetnotlist from regexpneg-list (dolist (var subsetnotlist) (delq var regexpneg-list)) ;; Check for keymap or create it (unless (keymapp 'regexpneg-keymap) (setq regexpneg-keymap (make-sparse-keymap)) (define-key regexpneg-keymap "\C-s" 'regexpneg-fwd) (define-key regexpneg-keymap " " 'regexpneg-fwd) (define-key regexpneg-keymap "\C-r" 'regexpneg-rev) (define-key regexpneg-keymap "DEL" 'regexpneg-rev) (define-key regexpneg-keymap "\C-j" 'exit-minibuffer) (define-key regexpneg-keymap "\C-m" 'exit-minibuffer)) ;; Set index-pointer (setq regexpneg-pointer 0) ;; Move to first match (goto-char (nth regexpneg-pointer regexpneg-list)) (message "buffer: %S, position: %d, pointer: %d" (current-buffer) (point) regexpneg-pointer) ;; Show minibuffer for further options (setq resp (read-from-minibuffer "REN: fwd=C-s,SPACE; rev=C-r,DEL; exit=C-j,C-m: " nil regexpneg-keymap)) (message "got response '%s'" resp)))