From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: Ligatures Date: Tue, 19 May 2020 17:36:44 +0200 Message-ID: <87367wszqr.fsf@gnu.org> References: <20200517124125.000013a4@web.de> <97C7EAB7-10AB-4702-ABC8-EB6C1C50ABDB@gnu.org> <20200517165953.000044d2@web.de> <83lflqblp0.fsf@gnu.org> <83ftbybio3.fsf@gnu.org> <83zha69xs2.fsf@gnu.org> <83367x9qeq.fsf@gnu.org> <83y2pp88lw.fsf@gnu.org> <83pnb182ce.fsf@gnu.org> <65807546-ed40-a175-640d-9da7a1548d8a@gmail.com> <83o8qk8xv6.fsf@gnu.org> <26ede471-3881-43e3-1253-6b21658343e9@gmail.com> <83lflo81qh.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="13931"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 19 17:38:46 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jb4KM-0003XJ-7U for ged-emacs-devel@m.gmane-mx.org; Tue, 19 May 2020 17:38:46 +0200 Original-Received: from localhost ([::1]:58606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb4KL-0005rU-9E for ged-emacs-devel@m.gmane-mx.org; Tue, 19 May 2020 11:38:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb4IW-0002G0-Hf for emacs-devel@gnu.org; Tue, 19 May 2020 11:36:52 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53764) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb4IW-0004u4-85; Tue, 19 May 2020 11:36:52 -0400 Original-Received: from auth1-smtp.messagingengine.com ([66.111.4.227]:34425) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1jb4IS-00021x-Mr; Tue, 19 May 2020 11:36:49 -0400 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 344D927C0054; Tue, 19 May 2020 11:36:48 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 19 May 2020 11:36:48 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddtjedgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtsehmtderredtreejnecuhfhrohhmpefvrghsshhi lhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnhepte egueevveethfejteekveejtdduhfetleeuteevteejgfffffdvfeevleehvdefnecukfhp peelfedrvdefiedrudefledrudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehthhhorhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgr lhhithihqdekieejfeekjeekgedqieefhedvleekqdhtshguhheppehgnhhurdhorhhgse hfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: from thinkpad-t440p (p5dec8baf.dip0.t-ipconnect.de [93.236.139.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 581BA306643C; Tue, 19 May 2020 11:36:46 -0400 (EDT) Mail-Followup-To: Eli Zaretskii , =?utf-8?Q?Cl=C3=A9ment?= Pit-Claudel , emacs-devel@gnu.org In-Reply-To: <83lflo81qh.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 19 May 2020 16:59:18 +0300") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:250955 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> > it be very common to deconstruct such ligatures, like =E2=86=92 into -= >? >> >=20 >> > No, I don't think so. Why would this be common? >>=20 >> I thought it would be the default. Emacs shows =E2=86=92, and you can pu= t the >> point either before (|=E2=86=92), in the middle (-|>), or after (=E2=86= =92|). > > Doesn't sound as a useful default to me. It could be an optional > feature, though. To me it sounds like a good default. >> Here's a fairly common case: when writing html or XML, you may type >> <, then >, then press C-b and type the tag name; or you may use < and >> a paredit-like setup that inserts the > automatically. If the font >> has a ligature for <> and you can't put the point in the middle, this >> breaks. Same for || =E2=80=94 the notation |x| { =E2=80=A6 } is used fo= r lambdas in >> some languages; if you type || then try to move the point back inside >> the composed || glyph it won't work. > > Sounds like a bug or misfeature that needs a solution, not necessarily > the one that's been proposed here. For example, how about a special > insert command that would disable ligation with the character it > inserts? I use the attached self-written ligature.el (Eli, you've helped me with that some months back). That's all nice but sometimes I too have the problem that I want to edit the name of a "private" function/variable foo--do-stuff and cannot move point inside the double-dash because it is composed as one char. As a little cure, I disable ligatures in the minibuffer where I absolutely need to do completion stuff like foo--bar. Another case is where when inserting < automatically inserts > immediately giving a <> diamond where I cannot move into. A special insert command will not help here because it is already inserted. Bye, Tassilo --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=ligature.el (defgroup ligature nil "Support for font ligatures" :version "28.1" :prefix "ligature-") (defcustom ligature-arrows (list "-->" "") "Ligatures for comments in XML-like languages." :type '(repeat string)) (defcustom ligature-hashes (list "##" "###" "####") "Ligatures for comments in languages with # being the comment character." :type '(repeat string)) (defcustom ligature-dots (list "..." "..") "Dot ligatures." :type '(repeat string)) (defcustom ligature-semicolons (list ";;" ";;;") "Ligatures for comments in lisp languages." :type '(repeat string)) (defun ligature--get-all () (append ligature-arrows ligature-relations ligature-operators ligature-misc ligature-dots ligature-comments-c-like ligature-comments-xml-like ligature-hashes ligature-semicolons)) (defun ligature--apply (ligatures) (let ((groups (seq-group-by #'string-to-char ligatures))) (dolist (group groups) (let ((c (car group)) (rx (regexp-opt (mapcar (lambda (s) (substring s 1)) (cdr group))))) (set-char-table-range composition-function-table c `([,(concat "." rx) 0 compose-gstring-for-graphic])))))) (define-minor-mode ligature-minor-mode "A mode for font ligatures." nil "" nil (if ligature-minor-mode (progn (when (minibufferp) (error "Cannot use ligature-minor-mode in minibuffer")) ;; FIXME: This doesn't work. When enabled, there will be a local ;; variable but the global value is the same (and also includes the ;; ligature composition rules). (ligature--apply (ligature--get-all))) ;; FIXME: Even if the above worked, this could remove much more than this ;; mode added itself. (kill-local-variable 'composition-function-table))) (defun ligature-minor-mode--apply-if-possible () (unless (minibufferp) (ligature-minor-mode))) (define-globalized-minor-mode global-ligature-minor-mode ligature-minor-mode ligature-minor-mode--apply-if-possible) (provide 'ligature) --=-=-=--