From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: gtr289@gmail.com Newsgroups: gmane.emacs.help Subject: Problem Undoing Text Properties In Gnu Emacs 24, Is this a bug? Date: Fri, 12 Dec 2014 14:02:56 -0800 (PST) Message-ID: <681ec09d-d836-48c9-af1f-fb19bd8bae03@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1418423060 17013 80.91.229.3 (12 Dec 2014 22:24:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Dec 2014 22:24:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 12 23:24:13 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XzYdA-0003mY-Mi for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Dec 2014 23:24:12 +0100 Original-Received: from localhost ([::1]:59655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzYd9-00039m-TN for geh-help-gnu-emacs@m.gmane.org; Fri, 12 Dec 2014 17:24:11 -0500 X-Received: by 10.236.2.226 with SMTP id 62mr14762322yhf.1.1418421776491; Fri, 12 Dec 2014 14:02:56 -0800 (PST) X-Received: by 10.140.84.170 with SMTP id l39mr31552qgd.33.1418421776461; Fri, 12 Dec 2014 14:02:56 -0800 (PST) Original-Path: usenet.stanford.edu!w8no6822693qac.0!news-out.google.com!r1ni50qat.1!nntp.google.com!w8no6822690qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.116.182.254; posting-account=tSYqGQoAAAAeSQ15qXX5aoJ3dafSnHkn Original-NNTP-Posting-Host: 76.116.182.254 User-Agent: G2/1.0 Injection-Date: Fri, 12 Dec 2014 22:02:56 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:209272 X-Mailman-Approved-At: Fri, 12 Dec 2014 17:24:00 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101552 Archived-At: Hello All, I'm seeing a problem in Gnu Emacs 24.3.1 with undoing some text properties = from some lisp code I wrote years ago as a light-weight C/C++ syntax highli= ghter that grays out C comments. I never had a problem with Gnu Emacs 19, = 20, 21 versions. I've tested this in Gnu Emacs 21.2.1 .=20 I work under Redhat 5 and also Cygwin and the problem exists in both. For s= ome reason, after turning on rear-nonsticky the undo ring breaks.=20 To illustrate the problem I've included a skimmed down .el file that shows= the basis of how it functions.=20 Put it as test.el in $HOME directory and run: "emacs -l ~/test.el" Set a buffer in c++-mode and type some junk after a start comment BUT DON'T= CLOSE THE COMMENT: ----> /* wejhjhjkr hjw hwre I used "red" for the comment color.. Now start hitting undo (f12) until all is gone and everything works fine. Now, in c++-mode do it again and CLOSE THE COMMENT AND PUT SOME JUNK AROUND= BOTH SIDES ---> eqwe eqweqwe eqwqe /* rrwrwr ewr rwrwe */ ewqeq eqeqeqw eqwe Start undoing with f12 key. It may not bug the first time but after a few a= ttempts the undo ring will get stuck.. Try it multiple times.. Is this a bug ? Why does it work in Emacs 21 ? Is there a fix for this ?= Or a remedy ? Any help is greatly appreciated.. Joe Below is the example code: ;;;;;;;;;;;;;;;;;;;;;;;;;; ; Disable font-lock-mode ; ;;;;;;;;;;;;;;;;;;;;;;;;;; (set-variable 'global-font-lock-mode nil)=20 (global-font-lock-mode 0) ;;;;;;;;;;;;;;;;; ; f12 is undo.. ; ;;;;;;;;;;;;;;;;; (global-unset-key [f12] ) (global-set-key [f12] 'undo) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Functions for setting text properties (maintain modify status) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun jk-set-text-properties (p1 p2 state) (interactive) (let ( (modflag (buffer-modified-p)) ) (set-text-properties p1 p2 state) (if (not modflag) (set-buffer-modified-p nil)))) (defun jk-add-text-properties (p1 p2 prop)=20 (interactive) (let ( (modflag (buffer-modified-p)) ) (add-text-properties p1 p2 prop) (if (not modflag) (set-buffer-modified-p nil)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; do-syntax looks for c+ comments --> /* ... */ ; 1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun do-syntax () =20 (interactive) (let () (cond ( (and (>=3D (point) 3) ;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;;;;;;;;; (equal (char-after (- (point) 2)) ?/ ) ;; we just type a start = of comment --> /* ; (equal (char-after (- (point) 1)) ?* ) ) ;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;;;;=20 =20 (setq savepos (point)) (save-excursion = ;;;;;;;;;;;;;;;;;=20 (jk-set-text-properties (- savepos 2) savepos '(face '(:foreground = "red") )) ;; turn on red ; ) = ;;;;;;;;;;;;;;;;; ) ( (and (> (point) 2) ;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;; (equal (char-after (- (point) 2)) ?* ) ;; we just typed close of c= omment --> */ ; (equal (char-after (- (point) 1)) ?/ ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;; =20 (setq savepos (point)) (save-excursion = ;;;;;;;;;;;;;;;;;;;;;; (jk-add-text-properties (-(point)1) (point) '(rear-nonsticky t )) = ;; End the comment ; ) = ;;;;;;;;;;;;;;;;;;;;;; )=20 ) ;; cond ) ;; let nil =20 ) ;; end do-syntax (setq post-command-hook nil) (add-hook 'post-command-hook (function=20 (lambda () (do-syntax))))