unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Problem Undoing Text Properties In Gnu Emacs 24,  Is this a bug?
@ 2014-12-12 22:02 gtr289
  2014-12-14  5:06 ` Michael Heerdegen
       [not found] ` <mailman.16016.1418533637.1147.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: gtr289 @ 2014-12-12 22:02 UTC (permalink / raw)
  To: help-gnu-emacs


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))))



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-17  1:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-12 22:02 Problem Undoing Text Properties In Gnu Emacs 24, Is this a bug? gtr289
2014-12-14  5:06 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).