branch: elpa/prop-menu commit 50b102c1c0935fd3e0c465feed7f27d66b21cdf3 Merge: 2b0de81 1edda80 Author: David Christiansen <da...@davidchristiansen.dk> Commit: David Christiansen <da...@davidchristiansen.dk>
Merge pull request #2 from david-christiansen/travis Initial Travis setup --- .travis.yml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 23 +++++++++++++++++++++++ prop-menu-tests.el | 35 +++++++++++++++++++++++++++++++++++ prop-menu.el | 35 +++++++++++++++++++++++++++++------ 4 files changed, 138 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9d7872a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,51 @@ +language: emacs-lisp +sudo: false + +cache: + directories: + - $HOME/emacs-24.3 + - $HOME/emacs-24.4 + - $HOME/emacs-24.5 + +before_install: + # Emacs 24.3 + - wget http://ftpmirror.gnu.org/emacs/emacs-24.3.tar.xz + - tar -xf emacs-24.3.tar.xz + - cd emacs-24.3 + - if [ ! -e bin/emacs ]; then ./configure --prefix=$HOME/emacs-24.3 --with-xpm=no --with-gif=no ; make ; make install ; fi + - cd .. + + # Emacs 24.4 + - wget http://ftpmirror.gnu.org/emacs/emacs-24.4.tar.xz + - tar -xf emacs-24.4.tar.xz + - cd emacs-24.4 + - if [ ! -e bin/emacs ]; then ./configure --prefix=$HOME/emacs-24.4 --with-xpm=no --with-gif=no ; make ; make install ; fi + - cd .. + + # Emacs 24.5 + - wget http://ftpmirror.gnu.org/emacs/emacs-24.5.tar.xz + - tar -xf emacs-24.5.tar.xz + - cd emacs-24.5 + - if [ ! -e bin/emacs ]; then ./configure --prefix=$HOME/emacs-24.5 --with-xpm=no --with-gif=no ; make ; make install ; fi + - cd .. + +before_script: true + +script: + # emacs 24.3 + - make getdeps EMACS=$HOME/emacs-24.3/bin/emacs + - make build EMACS=$HOME/emacs-24.3/bin/emacs + - make test EMACS=$HOME/emacs-24.3/bin/emacs + - make clean + + # emacs 24.4 + - make getdeps EMACS=$HOME/emacs-24.4/bin/emacs + - make build EMACS=$HOME/emacs-24.4/bin/emacs + - make test EMACS=$HOME/emacs-24.4/bin/emacs + - make clean + + # emacs 24.5 + - make getdeps EMACS=$HOME/emacs-24.5/bin/emacs + - make build EMACS=$HOME/emacs-24.5/bin/emacs + - make test EMACS=$HOME/emacs-24.5/bin/emacs + - make clean diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1a82d59 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +EMACS=emacs24 + +BATCHEMACS=$(EMACS) --batch --no-site-file -q -eval '(add-to-list (quote load-path) "${PWD}/")' -eval '(require (quote package))' -eval '(add-to-list (quote package-archives) (quote ("melpa" . "http://melpa.org/packages/")) t)' -eval '(package-initialize)' + +BYTECOMP = $(BATCHEMACS) -eval '(progn (require (quote bytecomp)) (setq byte-compile-warnings t) (setq byte-compile-error-on-warn t))' -f batch-byte-compile + +OBJS = prop-menu.elc + +.el.elc: + $(BYTECOMP) $< + +build: $(OBJS) + +test: + $(BATCHEMACS) -l ert -l prop-menu-tests.el -f ert-run-tests-batch-and-exit + +clean: + -rm -f $(OBJS) + +getdeps: + $(BATCHEMACS) -eval '(progn (package-refresh-contents))' + +.PHONY: clean build test diff --git a/prop-menu-tests.el b/prop-menu-tests.el new file mode 100644 index 0000000..91feb35 --- /dev/null +++ b/prop-menu-tests.el @@ -0,0 +1,35 @@ +;;; prop-menu-tests.el --- Tests for prop-menu -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 David Christiansen + +;; Author: David Christiansen <davidc@gungnir> +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Simple tests for prop-menu + +;;; Code: + +(require 'cl-lib) +(require 'prop-menu) + +(ert-deftest trivial-test () + (should t)) + + +(provide 'prop-menu-tests) +;;; prop-menu-tests.el ends here diff --git a/prop-menu.el b/prop-menu.el index bb92a2e..9277357 100644 --- a/prop-menu.el +++ b/prop-menu.el @@ -4,8 +4,8 @@ ;; Author: David Christiansen <da...@davidchristiansen.dk> ;; URL: https://github.com/david-christiansen/prop-menu-el -;; Package-Requires: ((emacs "24") (cl-lib "0.5")) -;; Version: 0.1.1 +;; Package-Requires: ((emacs "24.3") (cl-lib "0.5")) +;; Version: 0.1.2 ;; Keywords: convenience ;; This program is free software; you can redistribute it and/or modify @@ -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