From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cM+xDjHDTmAMGAAA0tVLHw (envelope-from ) for ; Mon, 15 Mar 2021 02:15:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qFiBCjHDTmDCJAAA1q6Kng (envelope-from ) for ; Mon, 15 Mar 2021 02:15:13 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 0A7A42939C for ; Mon, 15 Mar 2021 03:15:12 +0100 (CET) Received: from localhost ([::1]:39328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLclB-0002oQ-Eu for larch@yhetil.org; Sun, 14 Mar 2021 22:15:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLckm-0002o3-2w for emacs-orgmode@gnu.org; Sun, 14 Mar 2021 22:14:44 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:40035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLckj-0001Lh-95 for emacs-orgmode@gnu.org; Sun, 14 Mar 2021 22:14:42 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id CEB405C00E0 for ; Sun, 14 Mar 2021 22:14:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 14 Mar 2021 22:14:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=xP8cRW0Elez1wqNcdH9KE7F6/shof +PGyHWaPATCqV8=; b=vaMJe3gXhSzZxW8Z7Ng3i9bdymfYbtllmbxKtIlwIF3kl Vyx02ixDMVeEBSb/UhniQQrLmtHO1asr3c3BeyWTB+lxRPSsAdsnyzkqUw7w0jvP nyLmSrDl5Trchnz+oP0MDCbVTv/SmvWhipxSckdXj1e8zF6mJVD5EeaJiMHWWh/6 VKT7lYktjuOnNG9vaJKx6EMHYhyFEE7ruDPJgY88pqBLIh2FVVeteuwjWsxKqmIO 2+jmx8EDE3f9m07N1HetEOEOKJ032JMP0TljGTnhJG2n9+4B1FSROmNeQPUMZgbT coRO9byjTL8keAx/eveURjKDtMPOh17sj6mGYE9VA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddvkedggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffukffffgggtgesmhdtreertd efjeenucfhrhhomheppfhitghkucfurghvrghgvgcuoehnihgtkhesnhhitghkshgrvhgr ghgvrdgtrgeqnecuggftrfgrthhtvghrnhepjeduudevveehudelffelheffueetieegud ffheejleefvdegjeelveeifffgieejnecukfhppeejtddrhedvrddvgedrudekudenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehnihgtkhesnh hitghkshgrvhgrghgvrdgtrg X-ME-Proxy: Received: from [192.168.0.67] (bras-base-aylmpq0104w-grc-16-70-52-24-181.dsl.bell.ca [70.52.24.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 989A41080066 for ; Sun, 14 Mar 2021 22:14:38 -0400 (EDT) From: Nick Savage To: emacs-orgmode@gnu.org Subject: [PATCH] Improve code readability in org-set-font-lock-defaults Message-ID: <870e30e8-d912-df41-c5f7-6fa3f9be7fa2@nicksavage.ca> Date: Sun, 14 Mar 2021 22:14:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------977F758F1141B308D2AA83A2" Content-Language: en-US Received-SPF: none client-ip=66.111.4.25; envelope-from=nick@nicksavage.ca; helo=out1-smtp.messagingengine.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1615774513; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xP8cRW0Elez1wqNcdH9KE7F6/shof+PGyHWaPATCqV8=; b=Fu+hzoIHrLgAa8QcQxpTC/pvIZrMx8tAWo4gGASGlUZFaN8RMb5MDfzKkxBLdBEHezfuil CXgz3Geej1dFxyek9FultoYEtytM5l0Tb3S0Op33UvrbWZxVDIn5NEXf9+/6uS+ctroOJh UQT0Cb6Dx6AsyRp6MGTOMp6yDegC3xdmdDaVK5H9saArudOU7FpwTj9AoMAAoTbWHxGSoG UkxFJsNrf4DIDFmd0MPv7ckEG6Ag1gjDYp4I9xoI4SZKpwElHeu5Xj9JrAihO4K1rVoicM 3XWRHYS8TzzA4gMXW5gbcWWIl8mPHQ6kSJ5OhMfVxgkYIcB8t1HpzV9rcB217A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1615774513; a=rsa-sha256; cv=none; b=GAFvTcHik/NtiGkAEyFb3OPa0Z8oc2NdooCHqYCmWA7EWPM7kltdBCmNb6scVlshgbKqEu iI6ozjfq0b0syku5iwfbrii+UgTj5pwkHrI2rfforSMwiPr9QVvLezrGho98hWrWgTK4xu YmLU4GrwwCrIUz3DBIhR7szU1Sh++4KsgGFC372Wuj/m7UO2hu5ft/IdzoEu4Sbodpz5X5 DIitpit0AOZFk/oy9ET1WGuECjxt6xXKaefJY9p6OGyO36GYuWinH5QViXPjluB9I0Z7SD WqZyWki/17w+lILVr19EP1m+k9mDCrpMewveY79BlthjubHdQ4sQtq4ZVJHOOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=vaMJe3gX; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.60 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=vaMJe3gX; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 0A7A42939C X-Spam-Score: -2.60 X-Migadu-Scanner: scn0.migadu.com X-TUID: gj13+Ck1VhFO This is a multi-part message in MIME format. --------------977F758F1141B308D2AA83A2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I'm not sure what the appetite is for small changes like this, but I have attached a small patch to improve readability in org-set-font-lock-defaults. I was trying to understand how org-emphasize worked and came across some code that I thought could be simplified. If small refactoring patches like this aren't recommended or if I should wait until I have larger patches put together first before sending them to the list, please let me know. --------------977F758F1141B308D2AA83A2 Content-Type: text/x-patch; charset=UTF-8; name="0001-Refactor-org-set-font-lock-defaults-to-improve-code-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Refactor-org-set-font-lock-defaults-to-improve-code-.pa"; filename*1="tch" >From a7d5e226dd3b377edcc9c97dd83a8445ae67d952 Mon Sep 17 00:00:00 2001 From: Nicholas Savage Date: Sun, 14 Mar 2021 21:47:57 -0400 Subject: [PATCH] Refactor org-set-font-lock-defaults to improve code readability * org.el (org-set-font-lock-defaults): Reduce number of local variables to improve code readability. --- lisp/org.el | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 28596558b..d3c043a0c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5614,9 +5614,7 @@ needs to be inserted at a specific position in the font-lock sequence.") (defun org-set-font-lock-defaults () "Set font lock defaults for the current buffer." - (let* ((em org-fontify-emphasized-text) - (lk org-highlight-links) - (org-font-lock-extra-keywords + (let ((org-font-lock-extra-keywords (list ;; Call the hook '(org-font-lock-hook) @@ -5643,10 +5641,10 @@ needs to be inserted at a specific position in the font-lock sequence.") '(org-fontify-drawers) ;; Link related fontification. '(org-activate-links) - (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) - (when (memq 'radio lk) '(org-activate-target-links (1 'org-link t))) - (when (memq 'date lk) '(org-activate-dates (0 'org-date t))) - (when (memq 'footnote lk) '(org-activate-footnote-links)) + (when (memq 'tag org-highlight-links) '(org-activate-tags (1 'org-tag prepend))) + (when (memq 'radio org-highlight-links) '(org-activate-target-links (1 'org-link t))) + (when (memq 'date org-highlight-links) '(org-activate-dates (0 'org-date t))) + (when (memq 'footnote org-highlight-links) '(org-activate-footnote-links)) ;; Targets. (list org-radio-target-regexp '(0 'org-target t)) (list org-target-regexp '(0 'org-target t)) @@ -5690,7 +5688,7 @@ needs to be inserted at a specific position in the font-lock sequence.") (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t)) ;; Emphasis - (when em '(org-do-emphasis-faces)) + (when org-fontify-emphasized-text '(org-do-emphasis-faces)) ;; Checkboxes '("^[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\)[ \t]+\\(?:\\[@\\(?:start:\\)?[0-9]+\\][ \t]*\\)?\\(\\[[- X]\\]\\)" 1 'org-checkbox prepend) -- 2.20.1 --------------977F758F1141B308D2AA83A2--