From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: What is 0.01 here not 0.01 here 0.009999999999999? Date: Sat, 3 Apr 2021 08:36:10 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15037"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) Cc: Help Gnu Emacs mailing list , Stefan Monnier , John Yates To: Arthur Miller Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 03 07:38:30 2021 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 1lSYzO-0003oR-6o for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 03 Apr 2021 07:38:30 +0200 Original-Received: from localhost ([::1]:49466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lSYzN-0002B7-7o for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 03 Apr 2021 01:38:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSYyp-0002Ao-CS for help-gnu-emacs@gnu.org; Sat, 03 Apr 2021 01:37:55 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:58433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lSYyn-0005n5-Db for help-gnu-emacs@gnu.org; Sat, 03 Apr 2021 01:37:55 -0400 Original-Received: from localhost ([::ffff:41.202.241.42]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E1D8.000000006067FF2E.00001EAA; Fri, 02 Apr 2021 22:37:49 -0700 Mail-Followup-To: Arthur Miller , John Yates , Help Gnu Emacs mailing list , Stefan Monnier Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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:128836 Archived-At: * Arthur Miller [2021-04-03 07:41]: > > Because it is database backed, minimum interaction with the > > system is possible. In general, registered files are recorded in > > the database on each kill or save of the buffer, or by single > > key. I find it handy without any interactions. > > Two different ways, each part on it's own, or as one macro. Much simpler > than your decimal handling. I suggest to change your database scheme and > store those as integers there too so you don't need to convert back and > forth. Even better, skip the database and keep version number directly > in your paper which you hopefully write in an org file ;-). You know how version numbers may contain letters? That is why it is string. Those which do appear as `numeric' type, I can easily "cast": SELECT DISTINCT vc_revision::numeric FROM vc; vc_revision ------------- 1.23 1 1.19 0.02 Then I could also use PostgreSQL mathematics to increase the `numeric' cast: SELECT DISTINCT trunc(vc_revision::numeric, 2) FROM vc WHERE vc_id = 6826; trunc ------- 0.50 (1 row) rcdbusiness=# SELECT DISTINCT trunc(vc_revision::numeric + 0.01, 2) FROM vc WHERE vc_id = 6826; trunc ------- 0.51 Thus I could replace the function which I made in Emacs Lisp with PostgreSQL combination. These functions are insightful. I have to keep it a a note for later. As they need to be decided by author. Maybe some intelligence can be increased for computer to ask for a revision to be increased, depending on the quantity of text changed. > (defun rcd-vc-increase-major-number (version) > (aset version 0 (1+ (aref version 0)))) > > (defun rcd-vc-increase-minor-number (version) > (aset version 1 (1+ (aref version 1)))) > > (defun rcd-vc-increase-revision-number (version) > (aset version 2 (1+ (aref version 2)))) > > (defmacro incr-version (version-part version) > `(cond ((equal ,version-part 'major) > (aset ,version 0 (1+ (aref ,version 0)))) > ((equal ,version-part 'minor) > (aset ,version 1 (1+ (aref ,version 1)))) > ((equal ,version-part 'revision) > (aset ,version 2 (1+ (aref ,version 2)))))) > > (defun version-string (version) > (format "%s.%s.%s" (aref version 0) (aref version 1) (aref version 2))) > > Eaxmple of usage: > > (defvar my-version [0 0 0]) > > (rcd-vc-increase-revision-number my-version) > (version-string my-version) > > (incr-version 'major my-version) > (incr-version 'minor my-version) > (incr-version 'revision my-version) > (version-string my-version) -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns Sign an open letter in support of Richard M. Stallman https://rms-support-letter.github.io/