From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: Why is `C-x 8' limited to Latin-1 for search? Date: Sat, 8 Dec 2012 21:33:49 -0800 Message-ID: <9A96D353A11D47A7A143074DB1E09EE4@us.oracle.com> References: <1992681966EA4AE4A56751FA335DD5CE@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1355031246 4384 80.91.229.3 (9 Dec 2012 05:34:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Dec 2012 05:34:06 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 09 06:34:20 2012 Return-path: Envelope-to: ged-emacs-devel@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 1ThZWu-0005VA-6n for ged-emacs-devel@m.gmane.org; Sun, 09 Dec 2012 06:34:20 +0100 Original-Received: from localhost ([::1]:39672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThZWh-0001sF-Re for ged-emacs-devel@m.gmane.org; Sun, 09 Dec 2012 00:34:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThZWd-0001s4-Q6 for emacs-devel@gnu.org; Sun, 09 Dec 2012 00:34:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ThZWc-0001nE-C8 for emacs-devel@gnu.org; Sun, 09 Dec 2012 00:34:03 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:32526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ThZWc-0001nA-4P for emacs-devel@gnu.org; Sun, 09 Dec 2012 00:34:02 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qB95Y0uW015645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 9 Dec 2012 05:34:01 GMT Original-Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qB95XxN5004969 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 9 Dec 2012 05:33:59 GMT Original-Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id qB95Xwtv003988 for ; Sat, 8 Dec 2012 23:33:58 -0600 Original-Received: from dradamslap1 (/71.202.147.44) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 08 Dec 2012 21:33:58 -0800 X-Mailer: Microsoft Office Outlook 11 In-reply-to: <1992681966EA4AE4A56751FA335DD5CE@us.oracle.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Thread-Index: Ac3VyQty0XZpBIP3SRaXqsXI0t6BOQAAwSfA X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:155395 Archived-At: > To try the latter quickly (no, this is not the way to code=20 > this; it's just a quick way to let you try it): >=20 > (unless (fboundp 'ORIG-isearch-edit-string) > (defalias 'ORIG-isearch-edit-string > (symbol-function 'isearch-edit-string))) >=20 > (defun isearch-edit-string () > (interactive) > (let ((enable-recursive-minibuffers t)) > (ORIG-isearch-edit-string))) >=20 > In a buffer with some Unicode chars, e.g., `=EB': >=20 > C-s M-e C-x 8 RET GREEK SMALL LETTER LAMBDA C-s >=20 > (You have completion for the character name, at least.) And you can try the former quickly too (i.e., use `C-x 8 RET' directly = in Isearch without going through `M-e') with the code below. Again, I'm not proposing using this code as is; this is just to let you see how the = feature might act. E.g., after evaling the code below, to search for `abc=EBdef', do this = (with completion for the char name): C-s a b c C-x 8 RET GREEK SMALL LETTER LAMBDA RET d e f (define-key isearch-mode-map "\C-x8\r" 'foo) ;; 99% the same as `isearch-edit-string' (`M-e'). This just calls `read-char-by-name'. ;; The common code could be factored out, if this were how we wanted to implement the feature. ;; (I didn't try to see if everything else here is needed for this = feature, as it is needed for `M-e'.) ;; (defun foo () (interactive) (condition-case nil (progn (let ((enable-recursive-minibuffer t) ; <=3D=3D=3D=3D=3D=3D ADDED = =3D=3D=3D=3D (isearch-nonincremental isearch-nonincremental) ;; Locally bind all isearch global variables to protect them ;; from recursive isearching. ;; isearch-string -message and -forward are not bound ;; so they may be changed. Instead, save the values. (isearch-new-string isearch-string) (isearch-new-message isearch-message) (isearch-new-forward isearch-forward) (isearch-new-word isearch-word) (isearch-new-case-fold isearch-case-fold-search) (isearch-regexp isearch-regexp) (isearch-op-fun isearch-op-fun) (isearch-cmds isearch-cmds) (isearch-success isearch-success) (isearch-wrapped isearch-wrapped) (isearch-barrier isearch-barrier) (isearch-adjusted isearch-adjusted) (isearch-yank-flag isearch-yank-flag) (isearch-error isearch-error) (isearch-opoint isearch-opoint) (isearch-slow-terminal-mode isearch-slow-terminal-mode) (isearch-small-window isearch-small-window) (isearch-recursive-edit isearch-recursive-edit) ;; Save current configuration so we can restore it here. (isearch-window-configuration (current-window-configuration)) ;; This could protect the index of the search rings, ;; but we can't reliably count the number of typed M-p ;; in `read-from-minibuffer' to adjust the index accordingly. ;; So when the following is commented out, `isearch-mode' ;; below resets the index to the predictable value nil. ;; (search-ring-yank-pointer search-ring-yank-pointer) ;; (regexp-search-ring-yank-pointer regexp-search-ring-yank-pointer) ;; Temporarily restore `minibuffer-message-timeout'. (minibuffer-message-timeout isearch-original-minibuffer-message-timeout) (isearch-original-minibuffer-message-timeout isearch-original-minibuffer-message-timeout) old-point old-other-end) ;; Actually terminate isearching until editing is done. ;; This is so that the user can do anything without failure, ;; like switch buffers and start another isearch, and return. (condition-case nil (isearch-done t t) (exit nil)) ; was recursive editing ;; Save old point and isearch-other-end before reading from = minibuffer ;; that can change their values. (setq old-point (point) old-other-end isearch-other-end) (unwind-protect (let* ((message-log-max nil) ;; Don't add a new search string to the search = ring here ;; in `read-from-minibuffer'. It should be added = only ;; by `isearch-update-ring' called from = `isearch-done'. (history-add-new-input nil) ;; Binding minibuffer-history-symbol to nil is a work-around ;; for some incompatibility with gmhist. (minibuffer-history-symbol)) (setq isearch-new-string (concat isearch-string ;; =3D=3D=3D=3D=3D=3D=3D=3D=3D THIS IS ALL THAT'S = NEW =3D=3D=3D=3D=3D=3D=3D=3D=3D (string (read-char-by-name "Unicode (name or = hex): "))) isearch-new-message (mapconcat 'isearch-text-char-description isearch-new-string ""))) ;; Set point at the start (end) of old match if forward (backward), ;; so after exiting minibuffer isearch resumes at the start (end) ;; of this match and can find it again. (if (and old-other-end (eq old-point (point)) (eq isearch-forward isearch-new-forward)) (goto-char old-other-end)) ;; Always resume isearching by restarting it. (isearch-mode isearch-forward isearch-regexp isearch-op-fun nil isearch-word) ;; Copy new local values to isearch globals (setq isearch-string isearch-new-string isearch-message isearch-new-message isearch-forward isearch-new-forward isearch-word isearch-new-word isearch-case-fold-search isearch-new-case-fold)) ;; Empty isearch-string means use default. (when (=3D 0 (length isearch-string)) (setq isearch-string (or (car (if isearch-regexp regexp-search-ring search-ring)) "") isearch-message (mapconcat 'isearch-text-char-description isearch-string "")) ;; After taking the last element, adjust ring to previous one. (isearch-ring-adjust1 nil))) ;; This used to push the state as of before this C-s, but it adds ;; an inconsistent state where part of variables are from the ;; previous search (e.g. `isearch-success'), and part of variables ;; are just entered from the minibuffer (e.g. `isearch-string'). ;; (isearch-push-state) ;; Reinvoke the pending search. (isearch-search) (isearch-push-state) ; this pushes the correct state (isearch-update) (if isearch-nonincremental (progn ;; (sit-for 1) ;; needed if isearch-done does: (message "") (isearch-done) ;; The search done message is confusing when the string ;; is empty, so erase it. (if (equal isearch-string "") (message ""))))) (quit ; handle abort-recursive-edit (isearch-abort) ;; outside of let to restore outside global values )))