From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Magne Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: Bidirectional text and URLs Date: Sun, 30 Nov 2014 20:06:48 +0100 Organization: Programmerer Ingebrigtsen Message-ID: References: <87a93cngwv.fsf@uwakimon.sk.tsukuba.ac.jp> <837fyfml31.fsf@gnu.org> <874mtio7wh.fsf@uwakimon.sk.tsukuba.ac.jp> <83r3wml8kq.fsf@gnu.org> <83zjb9an0q.fsf@gnu.org> <831toka82r.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1417374458 20899 80.91.229.3 (30 Nov 2014 19:07:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Nov 2014 19:07:38 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 30 20:07:32 2014 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 1Xv9qE-0007GG-Sm for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2014 20:07:31 +0100 Original-Received: from localhost ([::1]:51446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv9qE-0003eM-CE for ged-emacs-devel@m.gmane.org; Sun, 30 Nov 2014 14:07:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv9pt-0003e5-2l for emacs-devel@gnu.org; Sun, 30 Nov 2014 14:07:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xv9pm-0003Cg-P2 for emacs-devel@gnu.org; Sun, 30 Nov 2014 14:07:08 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:60358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xv9pm-0003CX-JI for emacs-devel@gnu.org; Sun, 30 Nov 2014 14:07:02 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Xv9pj-00072d-GI for emacs-devel@gnu.org; Sun, 30 Nov 2014 20:06:59 +0100 Original-Received: from cm-84.215.51.58.getinternet.no ([84.215.51.58]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 30 Nov 2014 20:06:59 +0100 Original-Received: from larsi by cm-84.215.51.58.getinternet.no with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 30 Nov 2014 20:06:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 49 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cm-84.215.51.58.getinternet.no Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEXNtrKAa2MXExNKOzP+ 9+O0nJf+++b+/u726NX98t/k1c357dpMcH8oAAACbUlEQVQ4jXXUMY/aMBQH8MedXFWZCFGW285R 90ssPsBJvlzpFIS83ByF617B3KmBLB1StRELVcWBfCsDkb9c37MDhap9A0T55f/sOHFgIaVcrYw5 lLZM2zR1IWUKRVHksmkaQ1bh+VqmeK5wcBRj8HpJ52cEnTQI2EhamJ9aNbZV6xLzuYX0gWNF4lgv DuSofuAiEUkiBGHCX4qpBSkJUP4ARiBF+MYvCmFqx5D3PPJj3w8CTAQI827w/P4ysZ11ifwDy7K1 BleeN53PHKTPY98XIlRKjRUw8d22SvOiIAhErDJQ4F1CCEr5CgjW2dZBkRfPfojNJ0plk96N3nSQ y+L9uA+gr4fjm95a659fHEiZ7yADWF8J5imtte8SMk3ztwBM9QIBOvQQXAIfWP6E1wMEAWiRaT08 gpRP2AnWA5F5g6cNOwMd4/QhiYbAMhacwYZjhHE+BL0rf8U0+MwC43egxoLHOEK5TNys8OFLxW8z mIS+rzxdllcO9jbBQwhiXESNvT47aB1ESSTiUGUIyw5qGtxCFIY4SHV4PAHjieAcXwSfRi+nZ0CV wX+BsdDzln9B8I4BXIce2y0dLGq6Dx5lfRaywRCutXZQnaCnekmsAk8/2iWpGjtd3qcVHkRx4m22 HdT2Fb0loDmo5AhNQxD1gfUIBsLBogNcczWh/zg+hwhvXKmEkptgO89nedcKIYoVBe7WyZtP9V5a +MrdHsNE5Ong5eOP/ciCKQ1t/iWuedXWIzk6tA1Upiv7YagM7Wd5hIP9cUA7fVQuOjBHoIOmWS0x UZrTB8YmDGV0a6C8LIq0q/LVwO4fQlP5DWl1pk2Hz3mvAAAAAElFTkSuQmCC Mail-Copies-To: never X-Now-Playing: Depeche Mode's _The Singles 81-85_: "Shake The Disease" User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:Pz8BqKLIV8SY/v2fIQD0tHgaZVg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:178538 Archived-At: Ok, it was a bit longer than 7 lines, and I'm not quite sure what to do about further embedded LRM, RLM, ALM, LRE, RLE, LRO, RLO, PDF, LRI, RLI, FSI, PDI characters (perhaps just drop them?), but here's a kinda weak proof of concept. Eval the following, and you sort of get what you'd expect. (concat (string ?\x202e) "---" (ensure-left-to-right-string "http://אבג.דהוזחט.קום/yes/indeed.קום///")) ?\x202e is the right-to-left override. Compare with the output you get if you don't hack up the URL and sprinkle LROs: (concat (string ?\x202e) "---" "http://אבג.דהוזחט.קום/yes/indeed.קום///") (defun ensure-left-to-right-string (string) (let ((prev (get-char-code-property (aref string 0) 'bidi-class)) (start 0) (pos 0) (bits nil)) (while (< pos (length string)) (setq current (get-char-code-property (aref string pos) 'bidi-class)) (when (or (and (eq prev 'L) (memq current '(R AL))) (and (memq prev '(R AL)) (eq current 'L))) (push (substring string start pos) bits) (when (memq current '(L R AL)) (setq prev current)) (setq start pos)) (cl-incf pos)) (push (substring string start pos) bits) (mapconcat (lambda (bit) (if (cl-notany (lambda (char) (memq (get-char-code-property char 'bidi-class) '(R AL))) bit) ;; Wrap the string in LRO and PDF. (concat (string ?\x202d) bit (string ?\x202C)) ;; And RLO and PDF for the right-to-left bits. (concat (string ?\x202e) bit (string ?\x202C)))) (nreverse bits) ""))) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no