From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer Stengele Subject: Re: executing org-table TBLFM form changes (resets) language settings Date: Mon, 5 Mar 2018 15:39:08 +0100 Message-ID: References: <87inbphh77.fsf@alphaville.usersys.redhat.com> <59222bd6-d62a-23a4-544b-66466bdc3380@online.de> <45d4aef9-5e98-6153-0316-eaec502f5530@online.de> <87tvv3xdgu.fsf@nicolasgoaziou.fr> <87372mxp42.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esrGm-0000ii-2N for emacs-orgmode@gnu.org; Mon, 05 Mar 2018 09:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1esrGi-0005y3-G0 for emacs-orgmode@gnu.org; Mon, 05 Mar 2018 09:39:15 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:50715) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1esrGi-0005xO-4Z for emacs-orgmode@gnu.org; Mon, 05 Mar 2018 09:39:12 -0500 In-Reply-To: <87372mxp42.fsf@nicolasgoaziou.fr> Content-Language: de-DE-1901 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 Am 31.01.2018 um 12:08 schrieb Nicolas Goaziou: > Hello, > > Rainer Stengele writes: > >> I set the variables in my .emacs: >> >> (defvar math-short-weekday-names '( "So" "Mo" "Di" "Mi" "Do" "Fr" "Sa" )) > > Shouldn't it be (setq math-short-weekday-names '("So" ...)) > >> Very strange, no clue why that happens. > > No clue either. Calc is pretty foreign to me. You may want to ask Emacs > devel ML. > > Regards, > Hi, as nobody answered my calc question neither here nor in the emacs user group I am now using a work around. I rearranged my timestamp table from | IM Startzeit | IM Endezeit | Stunden | delta(x,16) | Anm. | |-----------------------+-----------------------+--------------+--------------+------| | [2018-01-22 Mo 19:30] | [2018-01-23 Di 14:30] | 19.00 | 3.00 | | #+TBLFM: $3=24*(date(<$2>)-date(<$1>)); %.2f::$4=$3-16.0; %.2f to | IM Startzeit -- IM Endezeit | Stunden - Min String | Delta | Anm. | |----------------------------------------------+----------------------+--------+------------------------------------------| | [2018-01-22 Mo 19:30]--[2018-01-23 Di 14:30] | 19.00 | 3.00 | | #+TBLFM: $2='(rst/org-evaluate-time-range)::$3=$2-16.0; %.2f I copied org-evaluate-time-range to rst/org-evaluate-time-range and modified the output slightly to give me a %2.2f hours based time range delta. Brutal, but works. Thank you. Regards, Rainer (defun rst/org-evaluate-time-range (&optional to-buffer) "Evaluate a time range by computing the difference between start and end. Normally the result is just printed in the echo area, but with prefix arg TO-BUFFER, the result is inserted just after the date stamp into the buffer. If the time range is actually in a table, the result is inserted into the next column. For time difference computation, a year is assumed to be exactly 365 days in order to avoid rounding problems." (interactive "P") (or (org-clock-update-time-maybe) (save-excursion (unless (org-at-date-range-p t) (goto-char (point-at-bol)) (re-search-forward org-tr-regexp-both (point-at-eol) t)) (unless (org-at-date-range-p t) (user-error "Not at a time-stamp range, and none found in current line"))) (let* ((ts1 (match-string 1)) (ts2 (match-string 2)) (havetime (or (> (length ts1) 15) (> (length ts2) 15))) (match-end (match-end 0)) (time1 (org-time-string-to-time ts1)) (time2 (org-time-string-to-time ts2)) (t1 (float-time time1)) (t2 (float-time time2)) (diff (abs (- t2 t1))) (negative (< (- t2 t1) 0)) ;; (ys (floor (* 365 24 60 60))) (ds (* 24 60 60)) (hs (* 60 60)) (fy "%dy %dd %02d:%02d") (fy1 "%dy %dd") (fd "%dd %02d:%02d") (fd1 "%dd") (fh "%02d:%02d") y d h m align) (if havetime (setq ; y (floor (/ diff ys)) diff (mod diff ys) y 0 d (floor (/ diff ds)) diff (mod diff ds) h (floor (/ diff hs)) diff (mod diff hs) m (floor (/ diff 60))) (setq ; y (floor (/ diff ys)) diff (mod diff ys) y 0 d (floor (+ (/ diff ds) 0.5)) h 0 m 0)) (if (not to-buffer) ;; RST changes here: ;; (message "%s" (org-make-tdiff-string y d h m)) (message "%2.2f" (+ (* 24 d) h (/ m 60.0))) (if (org-at-table-p) (progn (goto-char match-end) (setq align t) (and (looking-at " *|") (goto-char (match-end 0)))) (goto-char match-end)) (when (looking-at "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]") (replace-match "")) (when negative (insert " -")) (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m)) (if (> d 0) (insert " " (format (if havetime fd fd1) d h m)) (insert " " (format fh h m)))) (when align (org-table-align)) (message "Time difference inserted")))))