From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 6DGjKRG3ZGOBEQAAbAwnHQ (envelope-from ) for ; Fri, 04 Nov 2022 07:54:09 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0EGhKRG3ZGNASgEAauVa8A (envelope-from ) for ; Fri, 04 Nov 2022 07:54:09 +0100 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 376523C718 for ; Fri, 4 Nov 2022 07:54:08 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oqqZd-00055I-Kj; Fri, 04 Nov 2022 02:53:05 -0400 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 1oqqZb-00054E-Df for emacs-orgmode@gnu.org; Fri, 04 Nov 2022 02:53:03 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqqZZ-0006wr-1n for emacs-orgmode@gnu.org; Fri, 04 Nov 2022 02:53:03 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 35BDB240029 for ; Fri, 4 Nov 2022 07:52:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667544777; bh=2q7OV9ei7obcSxpJlWxU15dalclajFRvcdar5MYsDcw=; h=From:To:Cc:Subject:Date:From; b=G2oXsFkGEFc/n/mKh0XeKNgStF6pJvb3nl3x8+yAFIKzzVrXBr+Hbe6qEy72ss/ia nS9ReJ9ed3ZPbG44wCTWgNuHstuV5hBy1xjBTvqnN8hsHCa7NGr8NIldPBBDSlXBkF J5JWj9J13bBib+Pfm+2hxWW+BAN1nK4ZI/kj9cZNoANSShJxIJrdwHfaY04650ZQX6 2Hjz3Xrvi9vcxArho1F8ZBfKAZVIyLlyQqRWmJ2ln21zV670hMOBmqv4DQ/5p5huSE p0wTh9OBwD00vIO18NPg2xlROL08ULOWU0epdplwN3ljs+MfxpzgFY0EO09DwEfSOY atGubh9fNXS+A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N3WXl5dlYz6tn5; Fri, 4 Nov 2022 07:52:55 +0100 (CET) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] org.el: Warning for unsupported markers in `org-set-emphasis-alist' In-Reply-To: References: <87o86mw86r.fsf@localhost> <87fsrxkahq.fsf@nicolasgoaziou.fr> <87fsrxa1j5.fsf@localhost> <878rxoa6lk.fsf@localhost> <87pmqtj09r.fsf@localhost> Date: Fri, 04 Nov 2022 06:53:29 +0000 Message-ID: <87mt9743di.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667544849; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2Py+BB5o/I+rLcPQgXXCMeEyTzhJvjDFgpCxGIfXUjU=; b=Jq2B1k80uJQjokMH15pJifrQPpsNLy8mLD8abPyCciG5ec01HLuU4GBm3HbuGO4wnqDbKU BM6YtIdGwhNUmZltzJWV0ND2cBJbZju9reKb1GvtUd8a/inK/KHsXBKiAtUYPSyFczD6Na IqsAjVPkOmcrmldVDV2ELE0FE68vOdrd9RTe6nC+oqsUQUK+3NAbqKh+vW2wNyrt4TVu+E cqiPeHf5Jk2xVc9WpMV0ewUzp856SfvYAy/8g+dNyfaSriFt0AiFJokbXBJEXYF5TVAQBH wUIdIS6l2LyEAyayhOGKgy0z0pRaO8RQKwFbOLW0tVWHrmhNm7NVQ/WLaCIfcQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667544849; a=rsa-sha256; cv=none; b=QT3aIfNAwnuQiDygQ1aCBJbJ79HYx5nkRimtsT8kUZaaZ9ZoBy4WL+b7Emy/uWL+OmPdqz AF8YXS+o61BviZ35tORripc+vpkUZMCpinRNNiv1S7WoVgNjB67Lk2nYsau7FuKACCLuTy RPKU/r+dvJzznK2F5xNT6Bq3fCGiwsnnX+Iyml2OR8A/wu7cukbQDk4M67AzCv8s/JVCvf 6T09h4CgIM6SipqbvvVLxWkAWAMDwUdTdyOVEHsb7fFqS4occXLxGgyuMfCIHJxXaYgKXM Aw21r2IX/LAj7T+5ao9BxLXvG7Fdf/LLeldomYFd5mrKpOOiaGAqFtx1cpmN/g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=G2oXsFkG; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.50 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=G2oXsFkG; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 376523C718 X-Spam-Score: -3.50 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9AlzTCieYu0w --=-=-= Content-Type: text/plain Max Nikulin writes: > On 21/11/2021 17:01, Ihor Radchenko wrote: >> Max Nikulin writes: >> >>> My draft version is attached. Ihor, thank you for inspiration. Feel free >>> to improve it. I hope, it makes problem more apparent to user who tries >>> to customize markers. > > A patch is attached. I have dropped changes in documentation since I am > not the author of them. Sorry for the late reply. I have reviewed the patch, and I'd like to suggest a new version with the following changes: 1. Use `set-default-toplevel-value' instead of `set' that might be quirky in some scenarios. 2. Use `warn' instead of `message' as more alarming. 3. Remove verbatim in ("=" org-verbatim verbatim), ("~" org-code verbatim), and the :type spec. AFAIU, they are unused. But can you please double-check? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v3-0001-org.el-Warn-about-unsupported-markers-in-org-set-.patch >From 919fc426f298755886f6f3df22ce9670a7cf67c6 Mon Sep 17 00:00:00 2001 Message-Id: <919fc426f298755886f6f3df22ce9670a7cf67c6.1667544252.git.yantar92@posteo.net> From: Max Nikulin Date: Mon, 22 Nov 2021 23:56:15 +0700 Subject: [PATCH v3] org.el: Warn about unsupported markers in `org-set-emphasis-alist' * lisp/org.el (org-emphasis-alist, org-set-emphasis-alist): Change custom variable type definition and add :set parameter to warn users that non-standard marker characters are ignored. Remove unused third list entry from the default value. Attempts to introduce new markers have been discussed enough times to add some code that should prevent wasting of time. Unfortunately there is no way to issue warning for e.g. `setq'. Link: https://orgmode.org/list/878rxoa6lk.fsf@localhost --- lisp/org.el | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index d8708f8f2..43be34daf 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3628,12 +3628,31 @@ (defvar org-emphasis-regexp-components You need to reload Org or to restart Emacs after setting this.") +(defun org-set-emphasis-alist (var value) + "Set VAR (`org-emphasis-alist') to VALUE. +Warn user that Org syntax can not be extended with new emphasis +markers if such attempt is detected. The function is intended for +:set argument of `defcustom'." + (set-default-toplevel-value var value) + (let ((unsupported + (delq nil + (mapcar + (lambda (entry) + (let ((marker (car entry))) + (unless (member marker '("*" "/" "_" "=" "~" "+")) marker))) + value)))) + (when unsupported + (warn "Unsupported markup characters '%s' detected in `%s'" + (mapconcat #'identity unsupported " ") + (symbol-name var)))) + value) + (defcustom org-emphasis-alist '(("*" bold) ("/" italic) ("_" underline) - ("=" org-verbatim verbatim) - ("~" org-code verbatim) + ("=" org-verbatim) + ("~" org-code) ("+" (:strike-through t))) "Alist of characters and faces to emphasize text. Text starting and ending with a special character will be emphasized, @@ -3641,18 +3660,33 @@ (defcustom org-emphasis-alist marker characters and the face to be used by font-lock for highlighting in Org buffers. +Do not change the characters and do not add new ones to use custom +markers for existing styles or to introduce new styles. Org syntax is +not meant to be configurable and such modifications will not work with +export. + You need to reload Org or to restart Emacs after customizing this." :group 'org-appearance :set 'org-set-emph-re :version "24.4" :package-version '(Org . "8.0") + :set #'org-set-emphasis-alist :type '(repeat - (list - (string :tag "Marker character") - (choice - (face :tag "Font-lock-face") - (plist :tag "Face property list")) - (option (const verbatim))))) + (group + (choice + :tag "Marker" + (const :tag "*Bold*" "*") + (const :tag "/Italic/" "/") + (const :tag "_Underline_" "_") + (const :tag "+Strike-through+" "+") + (const :tag "=Verbatim=" "=") + (const :tag "~Code~" "~") + ;; To warn users that it does not work. + (string :tag "Unsupported ignored character")) + (choice + :tag "Font" + (face :tag "Face") + (plist :tag "Property list"))))) (defvar org-protecting-blocks '("src" "example" "export") "Blocks that contain text that is quoted, i.e. not processed as Org syntax. -- 2.35.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--