[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/prop-menu 97a0ab1 7/9: Make Emacs 24.3 happy
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/prop-menu 97a0ab1 7/9: Make Emacs 24.3 happy |
Date: |
Sun, 29 Aug 2021 11:29:15 -0400 (EDT) |
branch: elpa/prop-menu
commit 97a0ab12afc63f608106099f02439a8fa742182e
Author: David Raymond Christiansen <david@davidchristiansen.dk>
Commit: David Raymond Christiansen <david@davidchristiansen.dk>
Make Emacs 24.3 happy
This installs a compatiblity shim for Emacs 24.3, where elisp
programmers needed to implement their own sorting of overlays by
priority.
---
prop-menu.el | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/prop-menu.el b/prop-menu.el
index bb92a2e..32220fc 100644
--- a/prop-menu.el
+++ b/prop-menu.el
@@ -63,14 +63,37 @@ Major modes that provide context menus are expected to
populate
this variable with appropriate functions.")
(make-variable-buffer-local 'prop-menu-item-functions)
-(let ((counter 0))
- (defun prop-menu--unique-val ()
- (cl-incf counter)))
+(defvar prop-menu--unique-val-counter 0
+ "A global counter for unique values for prop-menu.")
+(defun prop-menu--unique-val ()
+ "Get a unique value for internal tagging."
+ (cl-incf prop-menu--unique-val-counter))
+
+(defun prop-menu--overlays-at (where)
+ "Return the overlays at location WHERE, sorted in order of priority."
+ (cond ((< emacs-major-version 24)
+ (error "Can't get overlays for prop-menu in Emacs versions < 24"))
+ ((and (= emacs-major-version 24)
+ (< emacs-minor-version 4))
+ ;; The SORTED argument to `overlays-at' was added in Emacs 24.4.
Here, we fake it.
+ (let ((overlays (overlays-at where)))
+ (sort overlays
+ #'(lambda (o1 o2)
+ (let ((p1 (or (overlay-get o1 'priority) 0))
+ (p2 (or (overlay-get o2 'priority) 0)))
+ (when (not (numberp p1)) (setq p1 0))
+ (when (not (numberp p2)) (setq p2 0))
+ (or (> p1 p2)
+ (and (= p1 p2)
+ (> (overlay-start o1) (overlay-start
o2)))))))))
+ ;; In Emacs 24.4 and up, we can just have Emacs do the sorting.
+ ;; Warnings are disabled here to not break CI for Emacs 24.3.
+ (t (with-no-warnings (overlays-at where t)))))
(defun prop-menu--items-for-location (where)
"Return the menu items based on the text properties and overlays at WHERE."
(let* ((text-props (text-properties-at where))
- (overlays (overlays-at where t))
+ (overlays (prop-menu--overlays-at where))
(overlay-props-list (mapcar #'overlay-properties overlays))
(props (prop-menu--merge-plists (cons text-props
overlay-props-list))))
(apply #'append
- [nongnu] branch elpa/prop-menu created (now 50b102c), ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 01ae5d4 1/9: Initial commit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 67db928 2/9: Increase the range of compatible Emacsen, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 0b38577 6/9: Initial Travis setup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 65df241 3/9: Remove stale testing code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 632ac43 4/9: Execute property-getting functions with point at click location, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 97a0ab1 7/9: Make Emacs 24.3 happy,
ELPA Syncer <=
- [nongnu] elpa/prop-menu 2b0de81 5/9: Get properties from correct window on click, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 50b102c 9/9: Merge pull request #2 from david-christiansen/travis, ELPA Syncer, 2021/08/29
- [nongnu] elpa/prop-menu 1edda80 8/9: Version bump, ELPA Syncer, 2021/08/29