From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mHwLJn4fnWGbHQEAgWs5BA (envelope-from ) for ; Tue, 23 Nov 2021 18:06:06 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KDPYIX4fnWGdWwAA1q6Kng (envelope-from ) for ; Tue, 23 Nov 2021 17:06:06 +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 4C572D07E for ; Tue, 23 Nov 2021 18:06:06 +0100 (CET) Received: from localhost ([::1]:33498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpZF7-00039F-CR for larch@yhetil.org; Tue, 23 Nov 2021 12:06:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpZEM-00037G-9M for emacs-orgmode@gnu.org; Tue, 23 Nov 2021 12:05:18 -0500 Received: from ciao.gmane.io ([116.202.254.214]:54118) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpZEI-00088j-Cs for emacs-orgmode@gnu.org; Tue, 23 Nov 2021 12:05:18 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mpZEF-000ABg-Ph for emacs-orgmode@gnu.org; Tue, 23 Nov 2021 18:05:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: [PATCH] org.el: Warning for unsupported markers in `org-set-emphasis-alist' Date: Wed, 24 Nov 2021 00:05:04 +0700 Message-ID: References: <87o86mw86r.fsf@localhost> <87fsrxkahq.fsf@nicolasgoaziou.fr> <87fsrxa1j5.fsf@localhost> <878rxoa6lk.fsf@localhost> <87pmqtj09r.fsf@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7CB9235FD9F92963F179F6E2" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 X-Woof-Patch: [PATCH] org.el: Warning for unsupported markers in `org-set-emphasis-alist' In-Reply-To: <87pmqtj09r.fsf@localhost> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" 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=1637687166; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=Y9+IzzSfoyWMiJ2qovaHqjiezLd77g1VlQoBKUO3ROc=; b=nb9gq+YsTGzGpVwvcHA4x00Y4VPKKiMyQmf8TKhaKmGiVLYFoySmayxT7o3Apn2HlidNTK CrpTJb27uoMW8P75uuIisB8Ck6d2gMtew6ktBmLt1dLEL+UL7519TP++mMi2Hei822ewUb K/+VIZgP3u4Fa/L0bRY6puIJKLBcSeFcNYQPUWopMSVGLmRpWYrvgHyD1CYJdZR5CSwtSh zl1thQra3GUT8P/kmerWrT/D01+qadw32WS7zctLastzYOP2ggvrvOFCPVy+P3WZKX7amK 8fAMn/hNOcxyakN4xSxARQfBU0LwlZkEW2UaZ820D+cMl2zF3jxdE5BZu8EsPw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637687166; a=rsa-sha256; cv=none; b=K9eJvorlHuY0U6+0m2ZzJSpf+VbZP97cJWB18UTNmgR0aL3kKKP1C8kPesKMJ5VoCwQUef deD2liYBVk96W7/3LCSepD5iYkiiPiKVfrxGnwSC9iCW8SBvrFjmhkgz/5AGHUlx6LCPJ4 p2RahAAR/ISyZmErY3YGiSazunwEBMEUlTwv/Kv4V170216KEBPCfl2lCzp6C/4mVSwQe6 EB2FYbouS4j9ngdMBY/soq4eWLwNvNX6FCsNFPLqOwSoOL4LPJQYB/PG2A8DyQEVvVvyhN MV5qaJBXDIv05nJpDO+QMw5HAZbQrCbNRx/IFD6f42BFWl/Xu4F+n9PJ0yMP0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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: -2.29 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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: 4C572D07E X-Spam-Score: -2.29 X-Migadu-Scanner: scn0.migadu.com X-TUID: ILjaEVGzRbx6 This is a multi-part message in MIME format. --------------7CB9235FD9F92963F179F6E2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. For init file (entries may be in arbitrary order) (custom-set-variables '(org-emphasis-alist (quote ( ("*" bold) ("_" underline) ("=" org-verbatim verbatim) ("/" italic) ("~" org-code verbatim) ("!" org-todo) ;; does not work ("+" (:strike-through t))))) ) emacs --eval "(customize-variable 'org-emphasis-alist)" looks as the following Hide Org Emphasis Alist: [INS] [DEL] : Marker: [Value Menu] *Bold* Font: [Value Menu] Face: (sample) bold [ ] verbatim [INS] [DEL] : Marker: [Value Menu] _Underline_ Font: [Value Menu] Face: (sample) underline [ ] verbatim [INS] [DEL] : Marker: [Value Menu] =Verbatim= Font: [Value Menu] Face: (sample) org-verbatim [X] verbatim [INS] [DEL] : Marker: [Value Menu] /Italic/ Font: [Value Menu] Face: (sample) italic [ ] verbatim [INS] [DEL] : Marker: [Value Menu] ~Code~ Font: [Value Menu] Face: (sample) org-code [X] verbatim [INS] [DEL] : Marker: [Value Menu] Unsupported ignored character: ! Font: [Value Menu] Face: (sample) org-todo [ ] verbatim [INS] [DEL] : Marker: [Value Menu] +Strike-through+ Font: [Value Menu] Property list: [INS] [DEL] : Key: :strike-through Value: t [INS] [ ] verbatim [INS] [ State ]: SAVED and set. --------------7CB9235FD9F92963F179F6E2 Content-Type: text/x-patch; charset=UTF-8; name="0001-org.el-Warning-for-unsupported-markers-in-org-set-em.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-org.el-Warning-for-unsupported-markers-in-org-set-em.pa"; filename*1="tch" >From 1ee52f7ffc1039fd442775e9267403f1dca86b88 Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Mon, 22 Nov 2021 23:56:15 +0700 Subject: [PATCH] org.el: Warning for 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. 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'. --- lisp/org.el | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index df3d139c7..1a65b6db8 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3771,6 +3771,25 @@ newline The maximum number of newlines allowed in an emphasis exp. 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 and check it for ignored characters. +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 var value) + (let ((unsupported + (delq nil + (mapcar + (lambda (entry) + (let ((marker (car entry))) + (unless (member marker '("*" "/" "_" "=" "~" "+")) marker))) + value)))) + (when unsupported + (message "Warning! Unsupported markup characters '%s' detected in `%s'" + (mapconcat #'identity unsupported " ") + (symbol-name var)))) + value) + (defcustom org-emphasis-alist '(("*" bold) ("/" italic) @@ -3784,18 +3803,34 @@ for example *bold*, _underlined_ and /italic/. This variable sets the 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")) + (option (const verbatim))))) (defvar org-protecting-blocks '("src" "example" "export") "Blocks that contain text that is quoted, i.e. not processed as Org syntax. -- 2.25.1 --------------7CB9235FD9F92963F179F6E2--