From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Adding colour when font-lock in disabled Date: Fri, 09 Dec 2022 14:06:23 +0200 Message-ID: <831qp82340.fsf@gnu.org> References: <838rjh12ar.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4651"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 09 13:07:13 2022 Return-path: Envelope-to: geh-help-gnu-emacs@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 1p3c9o-0000wj-Hu for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 09 Dec 2022 13:07:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3c9C-0000nC-IS; Fri, 09 Dec 2022 07:06:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3c9A-0000lG-JH for help-gnu-emacs@gnu.org; Fri, 09 Dec 2022 07:06:32 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3c9A-0006kH-9a for help-gnu-emacs@gnu.org; Fri, 09 Dec 2022 07:06:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=zU8DmjM+7a93cyRdHy5ZE7ZJ0Eb53Os9SjlLBhQMIf4=; b=FkxZIXEZ9TyS eaaU/ikn0XrVNxK0EXFhg5/fjoSG4uAXjgslPBBdUwX09tRtS2GUAOmpbh4IphhObkXXYluRRPoUR MJPGcpfe14MGHgi9lzbbrYhknAzdqKzHA22BRlc5RyXza7WbXLtQapdKioCqZc+VqSsbFDah8yq7W dDtlsX0YXicT5DDoHU3sWtYLikHrBnWDrCdrINL/4ygHRwy8eppoaojPeI4ex022hiDjMJtfyHJSU EE6ZaTz/xCmE/s6Vmgh63EmPTg4QUxBQhHzvM4nfSVP1urOXKCqvR09C2tFMjgZFRsapwE2sw47da O7b0FJkvhzy5b+/dQRVKCA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3c98-0003Sn-Gs for help-gnu-emacs@gnu.org; Fri, 09 Dec 2022 07:06:31 -0500 In-Reply-To: (message from Heime on Fri, 09 Dec 2022 08:09:08 +0000) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141504 Archived-At: > Date: Fri, 09 Dec 2022 08:09:08 +0000 > From: Heime > Cc: help-gnu-emacs@gnu.org > > > What is weird about it? font-lock-mode places face properties > > according to the mode's definitions, so it will overwrite any face > > properties you put manually. Thus the need to use a different > > property, which font-lock-mode doesn't control. > > But them when a user wants to introduce some text with some properties (e.g. colour), what is supposed to do. Users aren't supposed to introduce text properties, except via Lisp programs. > Would you expect someone to use font-lock-face when font-lock is enabled > > (propertize "G" 'font-lock-face '(:foreground "green")) > > -------- > > And use > > (propertize "G" 'face '(:foreground "green")) > > when font lock is disabled. The Lisp program which allows users to add faces should do something like that, yes. > Why places face properties according to the mode's definitions but not allow us to change the properties of inserted text, when we can do that anyway? Because font-lock must be in full control of face property to support the situation where the user edits the text, and as result the faces should change (e.g., because something that was previously just text became a comment or a string, or vice versa). > After calling a particular mode definitions, I should be able te change properties rather than having a lock. See above: the faces change dynamically to follow editing of the buffer text. It is not a one-time operation. If a user wants to highlight addition portions of the buffer, the user-level feature we provide is hi-lock-mode (a minor mode). It solves the complexity under the hood, and only requires the user to specify the patterns to highlight. So if you want an easy user-level interface, I suggest to use that minor mode.