From 676ab6ac9eacf5d7ab08913061e81b55c483e5a7 Mon Sep 17 00:00:00 2001 From: Chris Mann Date: Tue, 7 Oct 2008 23:16:21 +1030 Subject: [PATCH] * wesnoth-mode.el (line-number-at-pos): Define if necessary; not provided in Emacs21. (wesnoth-check-wml): Error when not wml data available. --- wesnoth-mode.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/wesnoth-mode.el b/wesnoth-mode.el index f7c8b51..ab49bc0 100644 --- a/wesnoth-mode.el +++ b/wesnoth-mode.el @@ -125,8 +125,7 @@ ;;; Code: (require 'cl) -;; The following provide completion data, but otherwise are not strictly -;; necessary. +;; The following provide WML data, but otherwise are not strictly necessary. (require 'wesnoth-wml-data nil t) (require 'wesnoth-update nil t) @@ -740,6 +739,21 @@ LAST-TAG is the parent element." (wesnoth-completion-available 'wesnoth-tag-data) :key position))))) +;; Define line-number-at-pos if necessary (not available in Emacs 21). +(unless (fboundp 'line-number-at-pos) + (defun line-number-at-pos (&optional pos) + "Return (narrowed) buffer line number at position POS. +If POS is nil, use current buffer location. +Counting starts at (point-min), so the value refers +to the contents of the accessible portion of the buffer." + (let ((opoint (or pos (point))) start) + (save-excursion + (goto-char (point-min)) + (setq start (point)) + (goto-char opoint) + (forward-line 0) + (1+ (count-lines start (point))))))) + (defun wesnoth-check-output (buffer format-string &rest args) "Output the string as passed to `format'. BUFFER is the buffer to output the result. @@ -756,6 +770,8 @@ ARGS is any additional data required by `format' to handle FORMAT-STRING." (interactive) (when (fboundp 'wesnoth-update-project-information) (funcall 'wesnoth-update-project-information)) + (unless (wesnoth-completion-available 'wesnoth-tag-data) + (error "WML data not available; can not generate report")) (let ((unmatched-tag-list '()) (outbuf (get-buffer-create "*WML*"))) (save-excursion -- 2.11.4.GIT