From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id mD0ZGzGW22P3LQEAbAwnHQ (envelope-from ) for ; Thu, 02 Feb 2023 11:53:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 0PkGGzGW22Nd6QAAauVa8A (envelope-from ) for ; Thu, 02 Feb 2023 11:53:37 +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 B75A355F5 for ; Thu, 2 Feb 2023 11:53:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNXD3-0005wV-B9; Thu, 02 Feb 2023 05:52:53 -0500 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 1pNXD1-0005pZ-5i for emacs-orgmode@gnu.org; Thu, 02 Feb 2023 05:52:51 -0500 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 1pNXCy-0003Id-Q0 for emacs-orgmode@gnu.org; Thu, 02 Feb 2023 05:52:50 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 0ABAB240373 for ; Thu, 2 Feb 2023 11:52:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1675335166; bh=6q/gJ1l5ki2IBs2NMuHNJaKYnGEJtFobNjnM96Qrgws=; h=From:To:Cc:Subject:Date:From; b=HFZ2PO+QQs0lfXJOQG/k07RB/nqWOiY8zetrowKj9w73D34j3EQSjDL2zGBEDubXU 3v1eFrhcMYdm5iTZthi7Pf8cHfjg1WzlQRYOf5pM0cza2lqyqzvXUq70KKgLgpM2c6 mcW8jmMM1vkrURFsLWYiNAmtngwYXgBrQgQ0bcjf1CIqbHFtQcpKDxDHx4YXe/birf wJ3Zj3QZtdSKRT6ZWvzbR7CfpqNylMnMSzgIhXoEyC74fa3LwnTlai5OTLWqyroMV+ fzKIgwGt9lDfsSZTk+sKq5xesJVmwNYblp+BzuBbwRvcjVGSj8sk/m3Ju3+VDJfya6 c744pDjfbi6AA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4P6wbw5Nq2z9rxF; Thu, 2 Feb 2023 11:52:44 +0100 (CET) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: [PATCH v5] org.el: Warning for unsupported markers in `org-set-emphasis-alist' In-Reply-To: <871qqhlskf.fsf@localhost> References: <87o86mw86r.fsf@localhost> <87fsrxkahq.fsf@nicolasgoaziou.fr> <87fsrxa1j5.fsf@localhost> <878rxoa6lk.fsf@localhost> <87pmqtj09r.fsf@localhost> <87mt9743di.fsf@localhost> <871qqhlskf.fsf@localhost> Date: Thu, 02 Feb 2023 10:53:20 +0000 Message-ID: <87r0v8pcdb.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: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1675335217; a=rsa-sha256; cv=none; b=iqsCT42oP+/OOlO+toksVvDt6aVXJIqFesTdu82Wj9rXPn8TzZ1bqtLp7d0z05LdLzF6/H NAILk487kUGcpLXSSeRv/H68P/YsziCTCIWAy6eJXzsVc5kJSgULSuduOqcysFpZqOjp6S 8uh8FCNMuU7raWcERW6icVdlEKQtrqwW3Z48wqoB0iV8BAeOmR+YayDmMUlG7blQsNb/PE UHwUYKYdFnU3SysHWlyU0bVbAMi4mSbLfcMDKgVlivgWOS07IiHGkA9btxcNWzkK5OwPYZ 8I4QDP3a6nGGXFGDu5ADXeL7uYpI0IXy8JWe6GCK/OhqSA/561Sf/+vCI6+sjw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=HFZ2PO+Q; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1675335217; 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=+QGcBTLq4ZwOm3W+4mA3XxMvWiXNmMQJOs/1uZNtEQI=; b=uIxR2f/Xer573NmZ8W7qklohgVqCBMs2RIXWTfc0aWXB9Xo0M8OzuvEdGwLR1ykzFK8hit SmS15kQN481+6nvv4PlMzPFEZvITPXFAUP2vf7JstJOv5C346iCxnkb9kjlrgV+Yywdp+N APyIUfon72k3CS6LPDaBNurQE6svzhDDjd/qxGDxoOXDDrBosB7VSQfLdJmn74JKN7sXBK 2RFurmtyyES7w8Sjfs4WPZTjMT01BbPWt4s6zgD87q1cEZlpbs2Sg08KzX+nJQkyOzY9/b RjK8tnOBYB8zg9L/ygXUVggAVU2Pk6k0P5AR+4Lxqrr7qmQvl6jo/LpuK9X5lQ== X-Migadu-Spam-Score: -9.55 X-Spam-Score: -9.55 X-Migadu-Queue-Id: B75A355F5 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=HFZ2PO+Q; 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-TUID: h06qRdtbZ7sV --=-=-= Content-Type: text/plain Ihor Radchenko writes: >> I think, verbatim option should not be removed from `defcustom' :type >> just now. For some users it might cause fallback to raw lisp value in >> easy customization UI. Perhaps another warning should be added to the >> `org-set-emphasis-alist' validator and the option should be labeled as >> unused in the :type definition. > > Makes sense. > What about the attached patch? > The idea is to tag the constant as deprecated. I further improved the patch adding variable watcher. This should catch everything. See the attached. Let me know if there are any objections. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v5-0001-org.el-Warn-about-unsupported-markers-in-org-set-.patch >From 78c61c6cc6fe95ab4d661c86ee8b3902a499cd0e Mon Sep 17 00:00:00 2001 Message-Id: <78c61c6cc6fe95ab4d661c86ee8b3902a499cd0e.1675335125.git.yantar92@posteo.net> From: Max Nikulin Date: Mon, 22 Nov 2021 23:56:15 +0700 Subject: [PATCH v5] org.el: Warn about unsupported markers in `org-set-emphasis-alist' * lisp/org.el (org-emphasis-alist): Change custom variable type definition. Remove unused third list entry from the default value. (org-emphasis-alist--check-value): New function used to warn the user when unsupported value is set. The function is used via `add-variable-watcher'. Attempts to introduce new markers have been discussed enough times to add some code that should prevent wasting of time. Link: https://orgmode.org/list/878rxoa6lk.fsf@localhost --- lisp/org.el | 56 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 1947c63a8..bc879e5d7 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3635,8 +3635,27 @@ (defvar org-verbatim-re nil (defvar org-emphasis-regexp-components) ; defined just below (defvar org-emphasis-alist) ; defined just below +(defun org-emphasis-alist--check-value (symbol value &optional operation _) + "Verify the VALUE of `org-emphasis-alist' SYMBOL. +Issue a warning when the value is not supported. +Optional argument OPERATION is intended for `add-variable-watcher' +usage, which see." + (when (memq operation '(set let)) + (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 symbol)))))) (defun org-set-emph-re (var val) - "Set variable and compute the emphasis regular expression." + "Set VAR to VAL and compute the emphasis regular expression. +The function is intended for :set argument of `defcustom' for +`org-emphasis-alist'." (set-default-toplevel-value var val) (when (and (boundp 'org-emphasis-alist) (boundp 'org-emphasis-regexp-components) @@ -3674,12 +3693,13 @@ (defvar org-emphasis-regexp-components You need to reload Org or to restart Emacs after setting this.") +(add-variable-watcher 'org-emphasis-alist #'org-emphasis-alist--check-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, @@ -3687,18 +3707,32 @@ (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") + :package-version '(Org . "9.7") :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")) + (option (const :tag "Deprecated ignored constant" verbatim))))) (defvar org-protecting-blocks '("src" "example" "export") "Blocks that contain text that is quoted, i.e. not processed as Org syntax. -- 2.39.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 --=-=-=--