all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: gtr289@gmail.com
To: help-gnu-emacs@gnu.org
Subject: Problem Undoing Text Properties In Gnu Emacs 24,  Is this a bug?
Date: Fri, 12 Dec 2014 14:02:56 -0800 (PST)	[thread overview]
Message-ID: <681ec09d-d836-48c9-af1f-fb19bd8bae03@googlegroups.com> (raw)


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 highlighter 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 . 

I work under Redhat 5 and also Cygwin and the problem exists in both. For some reason, after turning on rear-nonsticky the undo ring breaks. 

 To illustrate the problem I've included a skimmed down .el file that shows the basis of how it functions. 

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 attempts 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) 
(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) 
    (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 ()    
  (interactive)
  (let ()
    (cond
      (  (and (>= (point) 3)                          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	     (equal (char-after (- (point) 2)) ?/ )       ;; we just type a start of comment -->  /*   ;
	     (equal (char-after (- (point) 1)) ?* ) )     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
	 
	     (setq savepos (point))
	     (save-excursion                                                                    ;;;;;;;;;;;;;;;;; 
		    (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 comment -->  */  ;
	     (equal (char-after (- (point) 1)) ?/ ) )  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
           
	     (setq savepos (point))
	     (save-excursion                                                       ;;;;;;;;;;;;;;;;;;;;;;
	       (jk-add-text-properties  (-(point)1) (point) '(rear-nonsticky t ))  ;; End the comment   ;
         )                                                                     ;;;;;;;;;;;;;;;;;;;;;;
      ) 
    )  ;; cond
  ) ;; let
  nil          
) ;; end do-syntax


(setq  post-command-hook  nil)

(add-hook 'post-command-hook
     (function 
       (lambda ()
	 (do-syntax))))



             reply	other threads:[~2014-12-12 22:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12 22:02 gtr289 [this message]
2014-12-14  5:06 ` Problem Undoing Text Properties In Gnu Emacs 24, Is this a bug? Michael Heerdegen
     [not found] ` <mailman.16016.1418533637.1147.help-gnu-emacs@gnu.org>
2014-12-15 21:43   ` gtr289
2014-12-16 12:51     ` Michael Heerdegen
2014-12-17  1:53     ` Robert Thorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=681ec09d-d836-48c9-af1f-fb19bd8bae03@googlegroups.com \
    --to=gtr289@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.