From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Font-lock in a buffer inserted in Dired buffer? Date: Thu, 26 Nov 2020 17:21:09 +0100 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9259"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 26 17:37:51 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 1kiKHG-0002Gw-KM for ged-emacs-devel@m.gmane-mx.org; Thu, 26 Nov 2020 17:37:50 +0100 Original-Received: from localhost ([::1]:43992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kiKHF-0005Pw-Mq for ged-emacs-devel@m.gmane-mx.org; Thu, 26 Nov 2020 11:37:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kiKFm-0004kY-19 for emacs-devel@gnu.org; Thu, 26 Nov 2020 11:36:18 -0500 Original-Received: from mail-am6eur05olkn2019.outbound.protection.outlook.com ([40.92.91.19]:52448 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kiKFj-0004f1-Eg for emacs-devel@gnu.org; Thu, 26 Nov 2020 11:36:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HefsKEspvEcaBUryc76LmPXMGZlTvDgF+ZO+0d7hyfMoRFZZDnN1y5F9j56gFX1syJ84Y8cL7IcRvfUBZEN92w/Cydh8xchZwF804e0BpoTILXzugbP//IYUD3Iwi7/zhY0BUkc9g2My1n/wFiP1f+oEiSPVajwBmySJ6+oUy5yBu2+0PY2zn9OXzKE6bujJtLXedpMyPWd06e5Kpc73qY82QNkBYToR5OfI2fpcoIkLgKtmYPpo/bp5ysPooCmwYjDbbrud48T9C2VAZh64ntb7yBnp1ijsAAnqeDZTOiY2UfUmWqwqPREx/gHIqdfuv3RUQG3d7Ws1AxaaVQgTxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+GATfJnTbZnVdqvkxGvTRyH9iaweO0qYAzNUdVJ76mA=; b=C6jgqNFrqsRbJNtVi5yXubyuf+49I7GYT460alvbar/gZYzUqBu7obZz2MG79dFzJaSMMJm4g1uKRjcDFg8MRlL7xzNqivDdUuWNw6Sy/a3t7eXceQvwWUnUPLMtdUshd2AVCShYp8m1EF3JCkC/Gk8rEYPWy5wd1WSd9mdYHQ/w3ai16IHe6V6jbFhHiCzlGK1t3MSccTM2dWeZBXgRre8jV/l3ArEScYf2BeSKXXdye8hEV321Lg77/ujTJw2Ek+wGf4moYE7oc70aolz9M8LkXiqk/iehexlyJgAXNrPcH+051x6CZiYwdtRcneuf3n0t+HlIYobnBsJQhbSBBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+GATfJnTbZnVdqvkxGvTRyH9iaweO0qYAzNUdVJ76mA=; b=GFwaPtwO08H+VWSJlAq150G3XqyOmOWs9Y02Rr9XNzds/uLyBCPxA1REGz1Z3eFC5ofQclJ9UheXC2lFC5UtzompAullYlwbr3fPuzQ4KWln/jRiorZDy/cqiX2Zap2EVCl0xK2A6cjPBFbB7gUaCMUrtm0BEpuSS1PAQ2k4zkrA0sw6mIClIzHrVmLBrlHRJWkmeEaK4+rc31O9ujV9SVVfxKh8vtCfHQkSrQaDZetu3faL1xsmK3wJCreLckiOVafXPhwz3fcq46wtRYkE3p5vd18kmDsbFhyLvf4HqSvwnCl4eA9aaG+KgtdCBh4utCUeeWVB3JQ7E8SjaMIM9A== Original-Received: from VI1EUR05FT043.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::4b) by VI1EUR05HT083.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::391) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.20; Thu, 26 Nov 2020 16:21:10 +0000 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com (2a01:111:e400:fc12::46) by VI1EUR05FT043.mail.protection.outlook.com (2a01:111:e400:fc12::351) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.23 via Frontend Transport; Thu, 26 Nov 2020 16:21:10 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:7335E801EE08C723831BEBC782699C8681A774C822F41F5B5D1B91F811744FD1; UpperCasedChecksum:120BC1DB3D9770430241C322F5FEF4DA836822ED333CDB19B6D49089CB535650; SizeAsReceived:7217; Count:43 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993]) by AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993%7]) with mapi id 15.20.3611.024; Thu, 26 Nov 2020 16:21:10 +0000 X-TMN: [3O1wXglI8n7/5qXIkkzo6Ttu0NUJc3KZ] X-ClientProxiedBy: AM5PR1001CA0018.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::31) To AM0PR06MB6577.eurprd06.prod.outlook.com (2603:10a6:208:19a::23) X-Microsoft-Original-Message-ID: <87d0002ioa.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM5PR1001CA0018.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.20 via Frontend Transport; Thu, 26 Nov 2020 16:21:09 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 43 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 371c220a-0c64-4529-e110-08d8922748f5 X-MS-TrafficTypeDiagnostic: VI1EUR05HT083: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zkguy/RsKdJw9qo3goRWukx5SMCAkpufPZLnP0J1r41qpZbiGs9/03+HNsbTdQc3XaOqgXOHemJDfopfA4ZdbNwMtOPQXyVo1tZSjXL4kDu5d2LMVNkD+9RH0O2fr+If/F3nb7yA4K4CgxhI/35LEGYO5PSlMlkL3F9/RnrgMLBu8uxEgD48qX1cTwxtFd1cBA2EUym3dEYdDELKlnbQiw== X-MS-Exchange-AntiSpam-MessageData: Be9+Latb5S6663y9a8hdXl/0wpTFO7m/RJC6dAFFmJ3AAZX8GuZ6HTnrnLfPd3IUsdujxoUoFmLhgckFtHOnndeyfpZRnHgHfn+gHP/SiMxh7TD09Av+/GLGnXOIrTY0DVB8ylfsfqWlTsGrNxttaQ== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 371c220a-0c64-4529-e110-08d8922748f5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2020 16:21:10.2649 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT043.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR05HT083 Received-SPF: pass client-ip=40.92.91.19; envelope-from=arthur.miller@live.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:259843 Archived-At: --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=dired-auto-readme.el ;;; dired-auto-readme.el --- -*- lexical-binding: t; -*- ;; Copyright (C) 2020 Arthur Miller ;; Author: Arthur Miller ;; Keywords: ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . (defvar dired-auto-readme-files '("README" "README.md" "README.org" "README.txt") "List of README file names to automatically display. First file in the directory matching the list is used. ") (defun dired-auto-readme--insert () "Insert README file in the current buffer. " (setq inhibit-read-only t) (catch 'break (dolist (file dired-auto-readme-files) (when (file-exists-p file) (save-excursion (let ((readme-text)) (with-current-buffer (get-buffer-create file) (insert-file-contents file) (font-lock-ensure) (indent-region (point-min) (point-max)) (setq readme-text (buffer-substring (point-min) (point-max))) ;;(kill-buffer) ) (goto-char (point-max)) (make-variable-buffer-local 'dired-auto-readme--start-point) (setq dired-auto-readme--start-point (point)) (insert readme-text)) (setq dired-auto-readme--inserted t) (setq inhibit-read-only nil) (throw 'break t)))))) (defun dired-auto-readme--remove () (setq inhibit-read-only t) (save-excursion (goto-char dired-auto-readme--start-point) (delete-region (point) (point-max))) (setq dired-auto-readme--inserted nil) (setq inhibit-read-only t)) ;;;###autoload (define-minor-mode dired-auto-readme-mode "Dired minor mode to preview README in current directory." :global nil :lighter " README" (when (derived-mode-p 'dired-mode) (make-variable-buffer-local 'dired-auto-readme--inserted) (cond (dired-auto-readme-mode (unless dired-auto-readme--inserted (dired-auto-readme--insert)) ;; hook run by `dired-revert' (add-hook 'dired-after-readin-hook #'dired-auto-readme--insert nil t)) (t (when dired-auto-readme--inserted (dired-auto-readme--remove)) (remove-hook 'dired-after-readin-hook #'dired-auto-readme--insert t))))) (provide 'dired-auto-readme) ;;; dired-auto-readme.el ends here --=-=-= Content-Type: text/plain I am opening a file in it's own buffer, and hoping trying to get Emacs to font-lock it. I am not sure if font-lock will do it's thing when buffer is loaded or when it is displayed so I am calling (font-lock-ensure) to get it to (hopefully) kick-in. I see also dired is trying to font-lock inserted text. 1. what do I need to call to make it to font-lock 2. how do I tell Dired to give crap to font-lock the text after the insertion? Can I disable just a region from font-lock? Thanks for any help! --=-=-=--