From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Need to know how to goto-column Date: Sat, 05 Dec 2020 22:40:13 +0100 Message-ID: <87360kvsn6.fsf@web.de> References: <20201203114617.GF7554@tuxteam.de> <87mtyubk4v.fsf@web.de> <87o8jaa2hz.fsf@web.de> <877dpy9wz0.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28334"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 05 22:41:22 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1klfIv-0007I5-F8 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 22:41:21 +0100 Original-Received: from localhost ([::1]:56438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klfIt-0000Fc-5S for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 16:41:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klfIQ-0000F9-M3 for help-gnu-emacs@gnu.org; Sat, 05 Dec 2020 16:40:50 -0500 Original-Received: from mout.web.de ([212.227.15.4]:58939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klfIO-0000PK-FR for help-gnu-emacs@gnu.org; Sat, 05 Dec 2020 16:40:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1607204414; bh=vIY+XLXCh6usyCwfSlUyzhEkHMO/SA2GKrnWwT+2FvU=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=EXDtxjkx/AgTVYSMCQgBkfsWh+knLmhPVc8kI4brAbLWcDWZNQ4Nc4ednOPJdzayn UQPhTYUSZCvhK2UqlbGcf3fwFjodrq5XuuRPnZbRQa08bCZEahycwr6SMEP21XCW5i ZqYIlHyXJpi1x3omU3JS+X9WX57zUrDx6XkE3eD0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([94.218.219.247]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MSJ0V-1kZjCH2h7T-00TTI6; Sat, 05 Dec 2020 22:40:14 +0100 In-Reply-To: (Jean Louis's message of "Fri, 4 Dec 2020 09:01:48 +0300") X-Provags-ID: V03:K1:ulcnbVAeVvfHPOe9gJRwUV7EbfSN/R5EkfSRw31cfuuA47/qkxM pIDo6FnCgfc8Fq4dpFJBbjh/kthcQKSybVJ7vju+oMytArxuBtBZNE3YgJEG6Xd4JUUb8An XYNpnPYZknTl2tufjaJHcVBBa0CUmzAYGd5AW0MLVP/ESTFakcO1dg6GTFUAz3wt03tLQ51 3sVwpVgL7OWkcgcnMtK0g== X-UI-Out-Filterresults: notjunk:1;V03:K0:vwVbUjpQ16k=:TVL/rg1WlXkjS7OyDssaSq jr0X6QP0y9LNjsJjOGJZyinrNW6Pur504lXYt/9aIyThiq36O7mUqGBzl7QbtMOn9M2ToD2uL 5XcLmP2i8gqXMQLn10ilLeGFLe2Uf+4KBvhgqF6/kCpCDO7vbiP6iNxnlJu2w3cQc2ex8D8Fd VUftT7v3T3Qzfl7tMm7rpp0FfZjH2YfLCdBqZrgoqCWCVYE11CnXNFm/sSEbB6Y5H9GEppfNu 12wvvb/yOdMCXchQaaWoxwoB6ZGBL14+f7gg5RK4hZyn/yQfsAp6D+an8+nl36LXkNkXUaos0 iY12N9SBda70DqSRZ5rTRF+nMOzJW2IUH9Y3TppDV7gFzonv7jta+6bl63Cm2mhtOaSG/CDYq kUFp/nC9pYuM1G9+WJg4+R+DyrowkX8ikfrTSyUFHzrDR/BPetj3GBA372AYxAQ74BjXzSyRG mHQa6C75R4YT9jJWEWx//G6cXT1XQtnkZfmBKcSvOHA0/gp131Z9B1UDa9mY31MrWsWJuNfX2 hUXa+aLyGHYkJeyl/+cSuSZKMGdWe/hAI/Z4oIAF9pVL6/wahHp+6KCZFQVCj8QJXuYoRVLx8 t7h6Gz79b8yYS2p4HSvQOkKAb7let6TVUqO/qIlvnL9yXvvIs5lL3U1GMuCoujBx3LA1ipSlZ QJKBhnUw8g0PXhaJiSybr47rjMOIGBTE2hMRy7umaUv5Sx4N/aEjUY4n3snRLzVteSD9CoSew tic05lOlOW/Lz0DJwA5iWXpBT1AU7gc6NOlV14mSAPX0X2dxWEAph4E+bsZCmFI1F9M13gTo Received-SPF: pass client-ip=212.227.15.4; envelope-from=michael_heerdegen@web.de; helo=mout.web.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, 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: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:126048 Archived-At: Jean Louis writes: > Show me the `my-print-table-to-string' if you have it. Thrown together late at night and in a hurry, expect some nonsense errors (and a useless docstring): #+begin_src emacs-lisp (defun my-print-table-to-string (table &optional col-formatters alignments) "Print formatted TABLE, a matrix of strings, to a string and return it." (let* ((nb-cols (length (car table))) (fill (lambda (l) (let ((d (- nb-cols (length l)))) (if (< 0 d) (append l (make-list d nil)) l)))) (col-formatters (funcall fill col-formatters)) (alignments (funcall fill alignments)) (table (mapcar (lambda (line) (cl-mapcar (lambda (entry formatter) (if formatter (funcall formatter entry) entry)) line col-formatters)) table)) (max-col-lengths (mapcar (lambda (i) (apply #'max (mapcar #'length (mapcar (apply-partially #'nth i) table)))) (number-sequence 0 (1- nb-cols))))) (mapconcat (lambda (line) (let ((i 0)) (mapconcat #'identity (cl-mapcar (lambda (entry alignment) (prog1 (let ((padding (- (nth i max-col-lengths) (length entry)))) (pcase alignment ('right (concat (make-string padding ?\ ) entry)) ((and (or 'center 'centered) (let left (/ padding 2))) (concat (make-string left ?\ ) entry (make-string (- padding left) ?\ ))) (_ (concat entry (make-string padding ?\ ))))) (cl-incf i))) line alignments) " "))) table "\n"))) #+end_src Regards, Michael.