GNU bug report logs - #1425
Longlines mode not preserving text properties

Previous Next

Package: emacs;

Reported by: "Peter Seibel" <peter <at> gigamonkeys.com>

Date: Mon, 24 Nov 2008 23:30:03 UTC

Severity: normal

Tags: patch

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Chong Yidong <cyd <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#1425: closed (Longlines mode not preserving text properties)
Date: Fri, 30 Nov 2012 07:02:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 30 Nov 2012 14:58:47 +0800
with message-id <87mwxzpoew.fsf <at> gnu.org>
and subject line Re: bug#1425: Longlines mode not preserving text properties
has caused the debbugs.gnu.org bug report #1425,
regarding Longlines mode not preserving text properties
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
1425: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1425
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: "Peter Seibel" <peter <at> gigamonkeys.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Longlines mode not preserving text properties
Date: Mon, 24 Nov 2008 15:22:33 -0800
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the emacs-pretest-bug <at> gnu.org mailing list.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

I have some code that applies text properties via the
write-region-annotate-functions and after-insert-file-functions
mechanism in a major mode that also uses longlines-mode. When my text
properties span a soft newline longlines mode doesn't preserve them
when it converts spaces to newlines and back.

The following patch seems to fix my problem but perhaps someone who
groks longlines mode could come up with a more elegant solution.

--- longlines.el.orig	2008-11-24 14:50:17.000000000 -0800
+++ longlines.el	2008-11-24 14:58:22.000000000 -0800
@@ -240,7 +240,7 @@
 If wrapping is performed, point remains on the line.  If the line does
 not need to be wrapped, move point to the next line and return t."
   (if (longlines-set-breakpoint)
-      (progn (insert-before-markers ?\n)
+      (progn (insert-before-markers-and-inherit ?\n)
 	     (backward-char 1)
              (delete-char -1)
 	     (forward-char 1)
@@ -347,7 +347,13 @@
       (goto-char (min beg end))
       (while (search-forward "\n" reg-max t)
         (unless (get-text-property (match-beginning 0) 'hard)
-          (replace-match " ")))
+	  (let* ((pos (match-beginning 0))
+		 (props (text-properties-at pos nil)))
+	    (replace-match " ")
+	    (let* ((hard-start (member 'hard props))
+		   (after-hard (cddr hard-start))
+		   (newprops (nconc (ldiff props hard-start) after-hard)))
+	    (set-text-properties pos (1+ pos) newprops) nil))))
       (set-buffer-modified-p mod)
       end)))


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/Applications/Emacs.app/Contents/Resources/etc/DEBUG for instructions.


In GNU Emacs 22.0.99.1 (powerpc-apple-darwin8.9.0, Carbon Version 1.6.0)
 of 2007-05-06 on beagle
Windowing system distributor `Apple Inc.', version 10.4.11
configured using `configure  '--without-x' '--prefix=/usr/local''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: iso-8859-1
  default-enable-multibyte-characters: t

Major mode: Coders at Work Editing

Minor modes in effect:
  longlines-mode: t
  encoded-kbd-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-services-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-netsplit-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-autojoin-mode: t
  smart-quote-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  use-hard-newlines: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
n s SPC m e c h a n i s m . C-a M-q <down> <down> C-e
SPC I t SPC a l s o <M-backspace> <M-backspace> <backspace>
<backspace> SPC i n SPC a SPC m a j o r SPC m o d e
SPC t h a t SPC a l s o SPC u s e s SPC l o n g l i
n e s SPC m o d e . SPC T h e SPC M-b M-b <backspace>
- C-e t e x t SPC p r o p e r t i e s SPC M-b M-b M-b
C-k W h e n SPC m y SPC m e <backspace> <backspace>
t e x t SPC p r o p e r t i e s SPC s p a n SPC a SPC
s o f t SPC n e w l i n e SPC M-q C-a C-e SPC l o n
g <M-backspace> t h e SPC <M-backspace> l o n g l i
n e s SPC m o d e SPC M-b M-b C-e M-b C-e d o e s n
' t SPC p r e s e r v e SPC t h e m SPC w h e n SPC
i t SPC c o n v e r t s SPC s p a c e s SPC t o SPC
n e w l i n e s SPC a n d SPC b a c k . M-q C-a C-e
SPC <backspace> C-v C-v M-v M-v C-v M-< <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <up> <up> <down> C-SPC <up> <up> <up> <up> <up>
M-w C-x k <return> M-x r e p o r t <tab> <return>

Recent messages:
Making completion list...
Loading emacsbug...done
Quit
170 (#o252, #xaa)
1097 (#o2111, #x449)
Quit
Making completion list...
Mark set
Auto-saving...done
Mark set [2 times]


-- 
Peter Seibel
http://www.codersatwork.com/
http://www.gigamonkeys.com/blog/



[Message part 3 (message/rfc822, inline)]
From: Chong Yidong <cyd <at> gnu.org>
To: "Peter Seibel" <peter <at> gigamonkeys.com>
Cc: 1425-done <at> debbugs.gnu.org
Subject: Re: bug#1425: Longlines mode not preserving text properties
Date: Fri, 30 Nov 2012 14:58:47 +0800
"Peter Seibel" <peter <at> gigamonkeys.com> writes:

> I have some code that applies text properties via the
> write-region-annotate-functions and after-insert-file-functions
> mechanism in a major mode that also uses longlines-mode. When my text
> properties span a soft newline longlines mode doesn't preserve them
> when it converts spaces to newlines and back.
>
> The following patch seems to fix my problem but perhaps someone who
> groks longlines mode could come up with a more elegant solution.

Longlines mode has been quasi-obsoleted by Visual Line mode since this
bug was files (and soon to be formally obsoleted), but I've committed a
tweaked version of this patch that doesn't use ldiff.  Thanks.


This bug report was last modified 12 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.