From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EkXIARK3n2BjAQAAgWs5BA (envelope-from ) for ; Sat, 15 May 2021 13:57:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CGx2OBG3n2BqEAAAB5/wlQ (envelope-from ) for ; Sat, 15 May 2021 11:57:05 +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 2036423780 for ; Sat, 15 May 2021 13:57:05 +0200 (CEST) Received: from localhost ([::1]:59496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhsul-0004Tf-Cz for larch@yhetil.org; Sat, 15 May 2021 07:57:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhsuK-0004TX-Gv for emacs-orgmode@gnu.org; Sat, 15 May 2021 07:56:36 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:39157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhsuI-0001Q5-0K for emacs-orgmode@gnu.org; Sat, 15 May 2021 07:56:36 -0400 Received: (Authenticated sender: admin@nicolasgoaziou.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id EAA00240004; Sat, 15 May 2021 11:56:29 +0000 (UTC) From: Nicolas Goaziou To: Denis Maier Subject: Re: [wip-cite-new] Adjust punctuation around citations References: <871raawc7j.fsf@nicolasgoaziou.fr> <4dd47d8d-5dd8-4769-7e2f-eb3438ba0b4a@mailbox.org> Mail-Followup-To: Denis Maier , Org Mode List , Bruce D'Arcus Date: Sat, 15 May 2021 13:56:28 +0200 In-Reply-To: <4dd47d8d-5dd8-4769-7e2f-eb3438ba0b4a@mailbox.org> (Denis Maier's message of "Fri, 14 May 2021 10:42:28 +0200") Message-ID: <87sg2orz0z.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.193; envelope-from=mail@nicolasgoaziou.fr; helo=relay1-d.mail.gandi.net 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bruce D'Arcus , Org Mode List 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=1621079825; 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; bh=GWZVcWAJy5TRq+iL/qftE9oHZN8fIRe7OX+zUCli0Lc=; b=gTEyvMrBdrcQe1nCH5YNlpNhLFP701DIFdz5mu0oVdknaatEU3+jKbhiV9AW3ewfCkTEvn 0dMCVrHXgadXAv56wVMXBmH4duTBBaRkZ5E1oipx/eq8ffg2mn2QXK40Lfj/bEmboCzML4 P7IkUDjviR8QoI3LZBVIwwk5fkTr6eeL8DutOiZQfD4JTjc/LMi7ff82K5aDU7ZcSVIdjY ZRIAV+dfhhdPzMmMHhktvX0vVckGKfTpdGT+qzXDrcT6NMlseQjiDGqndw9aTfNVDQTcBg Gr/xTZ+kLdRrlB8+1mT4k6g5gyDNK5FSaEm/svUaGOZC3tNNemymg0N+73SKYQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621079825; a=rsa-sha256; cv=none; b=HE8N+HHBrVUlw2gWZjPtQiQxSir3Lz4E0BtxIA6/u61v9n3SyemMqs/O5jKgWzNo+2o1lo wAlqv808cNlUIHYJrWF75c6jPo8nwaJSz1Lw0PekdzhV5KlT/9QexU+G0Bsnvt+Q+DQDKM n9Agwgp8sxUvHyP/v/6Gfgnp/D6HQp+itII67oIWfzQvlLpdk21e1jNYSUXN7mFxbrl6UN 7eGvu64wr4iamq3RS1bDk1e7SWwKHp6YoAKXgythpkj3dMTsH+B9c2DKQ7hGF16HLkhX/I LWB0Ou7fkZWZqYULdBnRepHNPjfc8+MC6gV2L/eMQXvszQBMcycLYljsHMiOPQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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.45 Authentication-Results: aspmx1.migadu.com; dkim=none; 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: 2036423780 X-Spam-Score: -2.45 X-Migadu-Scanner: scn0.migadu.com X-TUID: bSb7Kat7jKuo Hello, Denis Maier writes: > Am 13.05.2021 um 23:33 schrieb Nicolas Goaziou: >> Hello, >> [...] >> RULE is a triplet of symbols (PUNCT POSITION RELATIVE): >> PUNCT is the desired location of the punctuation with regards >> to the >> quotation, if any. It may be `inside', `outside', or`strict', the latter >> meaning the punctuation should not be moved. >> POSITION is the desired location of the citation with regards >> to the >> quotation, if any. It may be `inside' or `outside'. >> RELATIVE is the relative position of the citation with regards >> to the closest >> punctuation. It may be `after' or `before'. >> For example, >> (inside outside after) corresponds to American typography; >> (strict outside after) corresponds to German typography; >> (strict inside before) corresponds to French typography. > These things are not only language dependent, but depend also on the > chosen citation style. E.g. with in-text styles you'll have (outside > outside before) in German, and American typography, in French likely > as well. Since the location of the punctuation is meaningful in French (and German), I have doubts about (outside ...) being appropriate. More on this below. > So, perhaps another setting: > #+type-of-citation-style: in-text > #+type-of-citation-style: note > > And ideally this RULE should be configurable directly as well: > #+punct-moving-rule: strict inside before > >> INFO is the export state, as a property list. >> Optional argument PUNCT is a list of punctuation marks to be >> considered. >> When nil, it includes the following: \".\" \",\" \";\" \":\" \"!\" and \"?\". > > Here as well, it should be possible to configure these on a user > level. Something like: > #+moved-punctuation: ,.?! > > WDYT? At the moment, the `org-cite-adjust-punctuation' function is designed with author-year to note conversion in mind, not the other way. I don't have enough examples of the opposite transformation to even be sure the current interface would be appropriate. I even believe this is not often possible, as it would imply rewording, i.e., add information that is not present in the original document. This doesn't seem to be a limitation, though. This feature is useful for users having to switch between author-year and note styles. The rule of thumb is to always write author-year in source. In any case, this explains why the docstring has a bias. I updated it to insist on the fact that these are rules for author-year to note conversion. Also, this function is not meant to be accessible to the end user. It is called from the processor, which knows the type (or style) of the citation. It may also choose not to use this function. So, I agree with Bruce D'Arcus: selecting an appropriate rule and punctuation ought to happen at that level. More importantly, I don't think fine-grain configuration is required. For specific needs, this "smart" feature should be disabled, and elements (punctuation, citation) positioned manually. But, again, if configuration is needed, the processor should provide it, e.g., through variables, not Org Cite. For example, a defcustom could offer to 1) not use this feature 2) rely on "language" keyword 3) apply a user-defined rule and punctuation set. What would be nice, however, would be an association between language and default rules and punctuation characters. WDYT? Meanwhile, I modified `org-cite-adjust-punctuation' function a bit. Here is its new docstring. --8<---------------cut here---------------start------------->8--- Adjust punctuation around CITATION object. When CITATION follows a quotation, or when there is punctuation next to it, the function tries to normalize the location of punctuation and citation according to some RULE. RULE is a triplet of symbols (PUNCTUATION CITE ORDER): PUNCTUATION is the desired location of the punctuation with regards to the quotation, if any. It may be `inside', `outside', or`static'. When set to `static', the punctuation is not moved. CITE is the desired location of the citation with regards to the quotation mark, if any. It may be `inside', `outside', or `same'. When set to `same', the citation is moved on the same side as the punctuation, but does not move if there is punctuation on both sides or on none. ORDER is the relative position of the citation with regards to the closest punctuation. It may be `after' or `before'. For example, when changing from author-date to note style, (inside outside after) corresponds to American typography; (static outside after) corresponds to German typography; (static same before) corresponds to French typography. INFO is the export state, as a property list. Optional argument PUNCT is a list of punctuation marks to be considered. When nil, it includes the following: \".\" \",\" \";\" \":\" \"!\" and \"?\". When optional argument ADD-SPACE is non-nil, add a space before citation. This is useful, for example, when switching from note to author-year style. Parse tree is modified by side-effect. Note: if you are calling both `org-cite-adjust-punctuation' and `org-cite-wrap-citation' on the same object, call `org-cite-adjust-punctuation' first. --8<---------------cut here---------------end--------------->8--- Note that previous `strict' became `static', and I introduced a `same' value for the second rule. I also added a new ADD-SPACE optional argument as an attempt to ease note to author-year style conversion. As written already in another message, you can test the following updated processor: --8<---------------cut here---------------start------------->8--- (defun org-test--language-to-rule (info) (pcase (plist-get info :language) ("en-us" '(inside outside after)) ((or "en" "de" "en-gb") '(static outside after)) ("fr" '(static same before)) (_ nil))) (defun org-test-export-citation (citation style _backend info) (pcase style ("author-year" (org-cite-adjust-punctuation citation '(outside outside before) info nil t) "(John Doe, 1999)") (_ (pcase (org-test--language-to-rule info) (`nil nil) (rule (org-cite-adjust-punctuation citation rule info))) (unless (org-cite-inside-footnote-p citation) (org-cite-wrap-citation citation info)) "..."))) (org-cite-register-processor 'test :export-citation #'org-test-export-citation) --8<---------------cut here---------------end--------------->8--- Regards, -- Nicolas Goaziou