From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel P Gomez Subject: Have SRC_BLOCK :padline accept numbers Date: Tue, 28 Mar 2017 21:47:42 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a113ff018b3edae054bcfbbdd Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1csx5l-0001kb-27 for emacs-orgmode@gnu.org; Tue, 28 Mar 2017 15:47:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1csx5k-0007jS-6V for emacs-orgmode@gnu.org; Tue, 28 Mar 2017 15:47:45 -0400 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:33365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1csx5k-0007jK-1M for emacs-orgmode@gnu.org; Tue, 28 Mar 2017 15:47:44 -0400 Received: by mail-qt0-x22a.google.com with SMTP id i34so73843932qtc.0 for ; Tue, 28 Mar 2017 12:47:43 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --001a113ff018b3edae054bcfbbdd Content-Type: multipart/alternative; boundary=001a113ff018b3eda8054bcfbbdb --001a113ff018b3eda8054bcfbbdb Content-Type: text/plain; charset=UTF-8 A use case is tangling python source code snippets containing class definitions. ( http://emacs.stackexchange.com/questions/31738/org-mode-babel-ensure-two-empty-lines-between-tangled-code-blocks-for-python ) Per PEP8, the use of blank lines stipulates: "Surround top-level function and class definitions with two blank lines." To achieve two blank lines before a class definition, one would have to set :padline 2. I've written a small patch (attached here), following the contribution guidelines on the org-mode website. The "patched" repository can be found here: https://github.com/dangom/org-mode/tree/feature_padline Please let me know if there is anything else I should do. Thanks, Daniel --001a113ff018b3eda8054bcfbbdb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Per PEP8, the use of blank lines sti= pulates:
"Surround top-level function and class definitions with tw= o blank lines."

To achieve two blank lines before a class definit= ion, one would have to set :padline 2.

I've written a smal= l patch (attached here), following the contribution guidelines on the org-m= ode website. The "patched" repository can be found here: https://github= .com/dangom/org-mode/tree/feature_padline

Please let me kn= ow if there is anything else I should do.

Thanks,

Daniel
--001a113ff018b3eda8054bcfbbdb-- --001a113ff018b3edae054bcfbbdd Content-Type: application/octet-stream; name="0001-Add-support-for-padline-with-numbers-in-ob-tangle.patch" Content-Disposition: attachment; filename="0001-Add-support-for-padline-with-numbers-in-ob-tangle.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j0tydpnk0 RnJvbSBmNWU2Nzg1NmI2Y2VmYjdjNWU5YzFiNmJkNzQzMjFkM2I0N2YxYjA1IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBEYW5pZWwgR29tZXogPGQuZ29tZXpAcG9zdGVvLm9yZz4KRGF0 ZTogVHVlLCAyOCBNYXIgMjAxNyAyMToyMDoyMyArMDIwMApTdWJqZWN0OiBbUEFUQ0hdIEFkZCBz dXBwb3J0IGZvciA6cGFkbGluZSB3aXRoIG51bWJlcnMgaW4gb2ItdGFuZ2xlLgoKLS0tCiBsaXNw L29iLXRhbmdsZS5lbCB8IDEzICsrKysrKysrKystLS0KIDEgZmlsZSBjaGFuZ2VkLCAxMCBpbnNl cnRpb25zKCspLCAzIGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2xpc3Avb2ItdGFuZ2xlLmVs IGIvbGlzcC9vYi10YW5nbGUuZWwKaW5kZXggYjMzZmNhZWU0Li44NWVhMThhNTcgMTAwNjQ0Ci0t LSBhL2xpc3Avb2ItdGFuZ2xlLmVsCisrKyBiL2xpc3Avb2ItdGFuZ2xlLmVsCkBAIC0yODQsOSAr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lCi0tIAoyLjEyLjIKCg== --001a113ff018b3edae054bcfbbdd-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Have SRC_BLOCK :padline accept numbers Date: Wed, 29 Mar 2017 14:27:00 +0200 Message-ID: <878tnoqne3.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctCgv-0001sv-L6 for emacs-orgmode@gnu.org; Wed, 29 Mar 2017 08:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctCgu-0003Ja-ED for emacs-orgmode@gnu.org; Wed, 29 Mar 2017 08:27:09 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:56350) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctCgu-0003JC-8e for emacs-orgmode@gnu.org; Wed, 29 Mar 2017 08:27:08 -0400 In-Reply-To: (Daniel P. Gomez's message of "Tue, 28 Mar 2017 21:47:42 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Daniel P Gomez Cc: emacs-orgmode@gnu.org Hello, Daniel P Gomez writes: > I've written a small patch (attached here), following the contribution > guidelines on the org-mode website. The "patched" repository can be found > here: https://github.com/dangom/org-mode/tree/feature_padline Thank you. > Please let me know if there is anything else I should do. Some comments follow. > From f5e67856b6cefb7c5e9c1b6bd74321d3b47f1b05 Mon Sep 17 00:00:00 2001 > From: Daniel Gomez > Date: Tue, 28 Mar 2017 21:20:23 +0200 > Subject: [PATCH] Add support for :padline with numbers in ob-tangle. > You need to add list modified functions here, with the actual modifiaction, e.g., * lisp/ob-tangle.el (the-function-I-modified): Been there, done that. Also, if you haven't signed FSF papers yet, you need to add "TINYCHANGE" at the end of the commit message. > - (unless (or (string= "no" (cdr (assq :padline (nth 4 spec)))) > - (= (point) (point-min))) > - (insert "\n")) > + (let ((padlines (format "%s" (cdr (assq :padline (nth 4 spec)))))) > + (cond > + ((and (string= "nil" padlines) (not (= (point) (point-min)))) (not (= (point) (point-min))) -> (not (bobp)) > + (insert "\n")) > + ((string= "no" padlines) > + nil) > + ((numberp (string-to-int padlines)) (numberp (string-to-int padlines)) -> (string-match-p "\\`[0-9]+\\'" padlines) > + (dotimes (i (string-to-int padlines)) (insert "\n"))) string-to-int -> string-to-number Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel P Gomez Subject: Re: Have SRC_BLOCK :padline accept numbers Date: Wed, 29 Mar 2017 18:03:12 +0200 Message-ID: References: <878tnoqne3.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctG43-00058K-Pg for emacs-orgmode@gnu.org; Wed, 29 Mar 2017 12:03:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctG42-0008MP-QB for emacs-orgmode@gnu.org; Wed, 29 Mar 2017 12:03:15 -0400 Received: from mail-qt0-x22e.google.com ([2607:f8b0:400d:c0d::22e]:34285) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctG42-0008Ly-MH for emacs-orgmode@gnu.org; Wed, 29 Mar 2017 12:03:14 -0400 Received: by mail-qt0-x22e.google.com with SMTP id n21so16613198qta.1 for ; Wed, 29 Mar 2017 09:03:14 -0700 (PDT) In-Reply-To: <878tnoqne3.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org Dear Nicolas, Thanks for the constructive feedback. I've amended the commit including the changes you've mentioned. I did not change the following, though: (numberp (string-to-int padlines)) -> (string-match-p "\\`[0-9]+\\'" padlines) because that changed the behaviour of org-babel-tangle. Having a string-match-p as a match condition broke the default of adding no padlines in the first tangled SRC block (when passed with no arguments). I also noticed that adding this functionality to ob-tangle breaks eldoc for me. I guess all org babel header arguments have to be strings? Debugger entered--Lisp error: (wrong-type-argument stringp 2) ((:padline . 2)) ((:results . "replace output") (:exports . "both") (:padline . 2) (:eval . "never-export") (:tangle . "no") (:hlines . "no") (:noweb . "no") (:cache . "no") (:session . "none")) " ") org-eldoc-get-src-header() org-eldoc-documentation-function() eldoc-print-current-symbol-info() GNU Emacs 25.2.1 (x86_64-apple-darwin16.4.0, NS appkit-1504.81 Version 10.12.3 (Build 16D32)) of 2017-03-22 Copyright (C) 2017 Free Software Foundation, Inc. Yours, Daniel Nicolas Goaziou writes: > Hello, > > Daniel P Gomez writes: > >> I've written a small patch (attached here), following the contribution >> guidelines on the org-mode website. The "patched" repository can be found >> here: https://github.com/dangom/org-mode/tree/feature_padline > > Thank you. > >> Please let me know if there is anything else I should do. > > Some comments follow. > >> From f5e67856b6cefb7c5e9c1b6bd74321d3b47f1b05 Mon Sep 17 00:00:00 2001 >> From: Daniel Gomez >> Date: Tue, 28 Mar 2017 21:20:23 +0200 >> Subject: [PATCH] Add support for :padline with numbers in ob-tangle. >> > You need to add list modified functions here, with the actual > modifiaction, e.g., > > * lisp/ob-tangle.el (the-function-I-modified): Been there, done that. > > Also, if you haven't signed FSF papers yet, you need to add "TINYCHANGE" > at the end of the commit message. > >> - (unless (or (string= "no" (cdr (assq :padline (nth 4 spec)))) >> - (= (point) (point-min))) >> - (insert "\n")) >> + (let ((padlines (format "%s" (cdr (assq :padline (nth 4 spec)))))) >> + (cond >> + ((and (string= "nil" padlines) (not (= (point) (point-min)))) > > (not (= (point) (point-min))) -> (not (bobp)) > >> + (insert "\n")) >> + ((string= "no" padlines) >> + nil) >> + ((numberp (string-to-int padlines)) > > (numberp (string-to-int padlines)) -> (string-match-p "\\`[0-9]+\\'" padlines) > >> + (dotimes (i (string-to-int padlines)) (insert "\n"))) > > string-to-int -> string-to-number > > > Regards, -- Daniel P. Gomez From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Have SRC_BLOCK :padline accept numbers Date: Thu, 30 Mar 2017 09:50:03 +0200 Message-ID: <87zig3nqz8.fsf@nicolasgoaziou.fr> References: <878tnoqne3.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctW1V-00077Q-4I for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 05:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctW1Q-0002UJ-3F for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 05:05:41 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:41554) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctW1P-0002Sz-Tr for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 05:05:36 -0400 In-Reply-To: (Daniel P. Gomez's message of "Wed, 29 Mar 2017 18:03:12 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Daniel P Gomez Cc: emacs-orgmode@gnu.org Hello, Daniel P Gomez writes: > I've amended the commit including the changes you've mentioned. Thank you. > I did not change the following, though: > > (numberp (string-to-int padlines)) -> (string-match-p "\\`[0-9]+\\'" padlines) > > because that changed the behaviour of org-babel-tangle. Having a > string-match-p as a > match condition broke the default of adding no padlines in the > first tangled SRC block (when passed with no arguments). I don't understand this. `string-to-int' and `string-match-p' both have the same requirements about parameters type, don't they? > I also noticed that adding this functionality to ob-tangle breaks eldoc > for me. I guess all org babel header arguments have to be strings? Probably. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Have SRC_BLOCK :padline accept numbers Date: Tue, 18 Apr 2017 10:37:53 +0200 Message-ID: <871ssq157i.fsf@nicolasgoaziou.fr> References: <878tnoqne3.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0Prq-0005Ud-VO for emacs-orgmode@gnu.org; Tue, 18 Apr 2017 05:56:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0Prn-0006Vg-Rp for emacs-orgmode@gnu.org; Tue, 18 Apr 2017 05:56:14 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:60221) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0Prn-0006Uu-Li for emacs-orgmode@gnu.org; Tue, 18 Apr 2017 05:56:11 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by relay7-d.mail.gandi.net (Postfix) with ESMTPS id BB6633839 for ; Tue, 18 Apr 2017 11:56:08 +0200 (CEST) In-Reply-To: (Daniel P. Gomez's message of "Wed, 29 Mar 2017 18:03:12 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Daniel P Gomez Cc: emacs-orgmode@gnu.org Hello, Daniel P Gomez writes: > I've amended the commit including the changes you've mentioned. > I did not change the following, though: > > (numberp (string-to-int padlines)) -> (string-match-p "\\`[0-9]+\\'" padlines) > > because that changed the behaviour of org-babel-tangle. Having a > string-match-p as a > match condition broke the default of adding no padlines in the > first tangled SRC block (when passed with no arguments). `string-to-int' will fail the same way as `string-match-p' if `padlines' is nil. So I do not see how the behaviour could differ. Could you elaborate on the issue? > I also noticed that adding this functionality to ob-tangle breaks eldoc > for me. I guess all org babel header arguments have to be strings? I didn't check, but that seems a reasonable assumption. BTW, you didn't include the patch, did you? Regards, -- Nicolas Goaziou 0x80A93738