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