[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 r116965: * src/buffer.c (Foverlays_at): Add argum
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] emacs-24 r116965: * src/buffer.c (Foverlays_at): Add argument `sorted'. |
Date: |
Tue, 15 Apr 2014 13:21:24 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 116965
revision-id: address@hidden
parent: address@hidden
committer: Stefan Monnier <address@hidden>
branch nick: emacs-24
timestamp: Tue 2014-04-15 09:21:18 -0400
message:
* src/buffer.c (Foverlays_at): Add argument `sorted'.
* doc/lispref/display.texi (Overlay Properties): Reword the doc of `priority'.
(Finding Overlays): Document new arg of `overlays-at'.
* lisp/obsolete/lucid.el (extent-at):
* lisp/htmlfontify.el (hfy-overlay-props-at): Use the new `sorted' arg of
overlays-at.
(hfy-fontify-buffer): Remove unused var `orig-ovls'.
* lisp/ps-def.el (ps-generate-postscript-with-faces1): Use the new `sorted'
arg of overlays-at. Use `invisible-p'.
modified:
doc/lispref/display.texi
display.texi-20091113204419-o5vbwnq5f7feedwu-6172
etc/NEWS news-20100311060928-aoit31wvzf25yr1z-1
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/htmlfontify.el
htmlfontify.el-20091119213711-g4mo9tswbas14kj6-2
lisp/obsolete/lucid.el lucid.el-20091113204419-o5vbwnq5f7feedwu-11410
lisp/ps-def.el psdef.el-20091113204419-o5vbwnq5f7feedwu-8533
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/buffer.c buffer.c-20091113204419-o5vbwnq5f7feedwu-264
=== modified file 'doc/lispref/display.texi'
--- a/doc/lispref/display.texi 2014-03-18 01:19:03 +0000
+++ b/doc/lispref/display.texi 2014-04-15 13:21:18 +0000
@@ -1475,8 +1475,10 @@
Since more than one overlay can specify a property value for the
same character, Emacs lets you specify a priority value of each
-overlay. You should not make assumptions about which overlay will
-prevail when there is a conflict and they have the same priority.
+overlay. In case two overlays have the same priority value, and one
+is nested in the other, then the inner one will have priority over the
+outer one. If neither is nested in the other then you should not make
+assumptions about which overlay will prevail.
These functions read and set the properties of an overlay:
@@ -1507,9 +1509,9 @@
@table @code
@item priority
@kindex priority @r{(overlay property)}
-This property's value (which should be a non-negative integer)
-determines the priority of the overlay. No priority, or @code{nil},
-means zero.
+This property's value determines the priority of the overlay. No priority, or
address@hidden, means zero. A non-nil and non-integer value has
+undefined behavior.
The priority matters when two or more overlays cover the same
character and both specify the same property; the one whose
@@ -1706,11 +1708,12 @@
@node Finding Overlays
@subsection Searching for Overlays
address@hidden overlays-at pos
-This function returns a list of all the overlays that cover the
-character at position @var{pos} in the current buffer. The list is in
-no particular order. An overlay contains position @var{pos} if it
-begins at or before @var{pos}, and ends after @var{pos}.
address@hidden overlays-at pos &optional sorted
+This function returns a list of all the overlays that cover the character at
+position @var{pos} in the current buffer. If @var{sorted} is non-nil, the list
+is in decreasing order of priority, otherwise it is in no particular order.
+An overlay contains position @var{pos} if it begins at or before @var{pos}, and
+ends after @var{pos}.
To illustrate usage, here is a Lisp function that returns a list of the
overlays that specify property @var{prop} for the character at point:
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2014-04-04 02:09:35 +0000
+++ b/etc/NEWS 2014-04-15 13:21:18 +0000
@@ -1219,6 +1219,8 @@
* Lisp Changes in Emacs 24.4
+** overlays-at can optionally sort its result by priority.
+
+++
** The second argument of `eval' can now specify a lexical environment.
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-04-14 22:01:54 +0000
+++ b/lisp/ChangeLog 2014-04-15 13:21:18 +0000
@@ -1,3 +1,13 @@
+2014-04-15 Stefan Monnier <address@hidden>
+
+ * ps-def.el (ps-generate-postscript-with-faces1): Use the new `sorted'
+ arg of overlays-at. Use `invisible-p'.
+
+ * obsolete/lucid.el (extent-at):
+ * htmlfontify.el (hfy-overlay-props-at): Use the new `sorted' arg of
+ overlays-at.
+ (hfy-fontify-buffer): Remove unused var `orig-ovls'.
+
2014-04-14 João Távora <address@hidden>
* net/shr.el (shr-expand-url): Use `expand-file-name' for relative
=== modified file 'lisp/htmlfontify.el'
--- a/lisp/htmlfontify.el 2014-03-04 03:18:55 +0000
+++ b/lisp/htmlfontify.el 2014-04-15 13:21:18 +0000
@@ -1328,9 +1328,7 @@
(defun hfy-overlay-props-at (p)
"Grab overlay properties at point P.
The plists are returned in descending priority order."
- (sort (mapcar #'overlay-properties (overlays-at p))
- (lambda (A B) (> (or (cadr (memq 'priority A)) 0) ;FIXME: plist-get?
- (or (cadr (memq 'priority B)) 0)))))
+ (mapcar #'overlay-properties (overlays-at p 'sorted)))
;; construct an assoc of (face-name . (css-name . "{ css-style }")) elements:
(defun hfy-compile-stylesheet ()
@@ -1642,7 +1640,6 @@
(css-map nil)
(invis-ranges nil)
(rovl nil)
- (orig-ovls (overlays-in (point-min) (point-max)))
(rmin (when mark-active (region-beginning)))
(rmax (when mark-active (region-end ))) )
(when (and mark-active
@@ -1664,12 +1661,6 @@
(set-buffer html-buffer)
;; rip out props that could interfere with our htmlization of the buffer:
(remove-text-properties (point-min) (point-max) hfy-ignored-properties)
- ;; Apply overlay invisible spec
- (setq orig-ovls
- (sort orig-ovls
- (lambda (A B)
- (> (or (cadr (memq 'priority (overlay-properties A))) 0)
- (or (cadr (memq 'priority (overlay-properties B))) 0)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; at this point, html-buffer retains the fontification of the parent:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
=== modified file 'lisp/obsolete/lucid.el'
--- a/lisp/obsolete/lucid.el 2014-02-10 01:34:22 +0000
+++ b/lisp/obsolete/lucid.el 2014-04-15 13:21:18 +0000
@@ -125,7 +125,7 @@
(defun extent-at (pos &optional object property before)
(with-current-buffer (or object (current-buffer))
- (let ((overlays (overlays-at pos)))
+ (let ((overlays (overlays-at pos 'sorted)))
(when property
(let (filtered)
(while overlays
@@ -133,14 +133,6 @@
(setq filtered (cons (car overlays) filtered)))
(setq overlays (cdr overlays)))
(setq overlays filtered)))
- (setq overlays
- (sort overlays
- (function (lambda (o1 o2)
- (let ((p1 (or (overlay-get o1 'priority) 0))
- (p2 (or (overlay-get o2 'priority) 0)))
- (or (> p1 p2)
- (and (= p1 p2)
- (> (overlay-start o1) (overlay-start
o2)))))))))
(if before
(nth 1 (memq before overlays))
(car overlays)))))
=== modified file 'lisp/ps-def.el'
--- a/lisp/ps-def.el 2014-01-01 07:43:34 +0000
+++ b/lisp/ps-def.el 2014-04-15 13:21:18 +0000
@@ -339,53 +339,11 @@
(setq position (min property-change overlay-change)
before-string nil
after-string nil)
- ;; The code below is not quite correct,
- ;; because a non-nil overlay invisible property
- ;; which is inactive according to the current value
- ;; of buffer-invisibility-spec nonetheless overrides
- ;; a face text property.
(setq face
- (cond ((let ((prop (get-text-property from 'invisible)))
- ;; Decide whether this invisible property
- ;; really makes the text invisible.
- (if (eq save-buffer-invisibility-spec t)
- (not (null prop))
- (or (memq prop save-buffer-invisibility-spec)
- (assq prop save-buffer-invisibility-spec))))
+ (cond ((invisible-p from)
'emacs--invisible--face)
- ((get-text-property from 'face))
+ ((get-char-property from 'face))
(t 'default)))
- (let ((overlays (overlays-at from))
- (face-priority -1)) ; text-property
- (while (and overlays
- (not (eq face 'emacs--invisible--face)))
- (let* ((overlay (car overlays))
- (overlay-invisible
- (overlay-get overlay 'invisible))
- (overlay-priority
- (or (overlay-get overlay 'priority) 0)))
- (and (> overlay-priority face-priority)
- (setq before-string
- (or (overlay-get overlay 'before-string)
- before-string)
- after-string
- (or (and (<= (overlay-end overlay) position)
- (overlay-get overlay 'after-string))
- after-string)
- face-priority overlay-priority
- face
- (cond
- ((if (eq save-buffer-invisibility-spec t)
- (not (null overlay-invisible))
- (or (memq overlay-invisible
- save-buffer-invisibility-spec)
- (assq overlay-invisible
- save-buffer-invisibility-spec)))
- 'emacs--invisible--face)
- ((overlay-get overlay 'face))
- (t face)
- ))))
- (setq overlays (cdr overlays))))
;; Plot up to this record.
(and before-string
(ps-plot-string before-string))
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-04-14 15:32:27 +0000
+++ b/src/ChangeLog 2014-04-15 13:21:18 +0000
@@ -1,3 +1,7 @@
+2014-04-15 Stefan Monnier <address@hidden>
+
+ * buffer.c (Foverlays_at): Add argument `sorted'.
+
2014-04-14 Eli Zaretskii <address@hidden>
* insdel.c (invalidate_buffer_caches): When deleting or replacing
=== modified file 'src/buffer.c'
--- a/src/buffer.c 2014-03-23 22:30:47 +0000
+++ b/src/buffer.c 2014-04-15 13:21:18 +0000
@@ -4168,9 +4168,10 @@
}
-DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0,
- doc: /* Return a list of the overlays that contain the character at
POS. */)
- (Lisp_Object pos)
+DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 2, 0,
+ doc: /* Return a list of the overlays that contain the character at POS.
+If SORTED is non-nil, then sort them by decreasing priority. */)
+ (Lisp_Object pos, Lisp_Object sorted)
{
ptrdiff_t len, noverlays;
Lisp_Object *overlay_vec;
@@ -4190,6 +4191,10 @@
noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len,
NULL, NULL, 0);
+ if (!NILP (sorted))
+ noverlays = sort_overlays (overlay_vec, noverlays,
+ WINDOWP (sorted) ? XWINDOW (sorted) : NULL);
+
/* Make a list of them all. */
result = Flist (noverlays, overlay_vec);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 r116965: * src/buffer.c (Foverlays_at): Add argument `sorted'.,
Stefan Monnier <=