From ee7aa9878f4ae76fce63be763e7825c654719f1b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 23 Jun 2016 15:20:32 +0200 Subject: [PATCH] Deprecate `org-no-warnings' in favor of `with-no-warnings' * lisp/org-macs.el (org-no-warnings): Rewove macro. * lisp/org-compat.el (org-no-warnings): Mark `org-no-warnings' as obsolete. * contrib/lisp/org-contacts.el (defvar): * contrib/lisp/org-wl.el (org-wl-open): * lisp/org-agenda.el (defvar): (org-anniversary): (org-cyclic): (org-block): (org-date): * lisp/org-bbdb.el (defvar): * lisp/org-clock.el (org-clock-out): (org-clock-cancel): * lisp/org-mouse.el (org-mouse-show-context-menu): * lisp/org.el (org-modify-ts-extra): (org-order-calendar-date-args): Small refactoring. * lisp/ox-odt.el (org-odt-htmlfontify-string): --- contrib/lisp/org-contacts.el | 2 +- contrib/lisp/org-wl.el | 4 ++-- lisp/org-agenda.el | 12 ++++++------ lisp/org-bbdb.el | 2 +- lisp/org-clock.el | 4 ++-- lisp/org-colview.el | 4 +--- lisp/org-compat.el | 1 + lisp/org-macs.el | 4 ---- lisp/org-mouse.el | 2 +- lisp/org.el | 18 +++++------------- lisp/ox-odt.el | 2 +- 11 files changed, 21 insertions(+), 34 deletions(-) diff --git a/contrib/lisp/org-contacts.el b/contrib/lisp/org-contacts.el index 797aa29ff..72269de7e 100644 --- a/contrib/lisp/org-contacts.el +++ b/contrib/lisp/org-contacts.el @@ -674,7 +674,7 @@ description." (goto-char marker) (when (eq major-mode 'org-mode) (org-show-context 'agenda))))) -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar date)) ;; unprefixed, from calendar.el (defun org-contacts-anniversaries (&optional field format) "Compute FIELD anniversary for each contact, returning FORMAT. Default FIELD value is \"BIRTHDAY\". diff --git a/contrib/lisp/org-wl.el b/contrib/lisp/org-wl.el index 5fd42d132..00bbf3253 100644 --- a/contrib/lisp/org-wl.el +++ b/contrib/lisp/org-wl.el @@ -279,8 +279,8 @@ for namazu index." org-wl-namazu-default-index) org-wl-namazu-default-index (read-directory-name "Namazu index: "))))) - (if (not (elmo-folder-exists-p (org-no-warnings - (wl-folder-get-elmo-folder folder)))) + (if (not (elmo-folder-exists-p (with-no-warnings + (wl-folder-get-elmo-folder folder)))) (error "No such folder: %s" folder)) (let ((old-buf (current-buffer)) (old-point (point-marker))) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 426113ce5..6a572d9db 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -96,8 +96,8 @@ (defvar org-agenda-buffer-name "*Org Agenda*") (defvar org-agenda-overriding-header nil) (defvar org-agenda-title-append nil) -(org-no-warnings (defvar entry)) ;; unprefixed, from calendar.el -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar entry)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar date)) ;; unprefixed, from calendar.el (defvar original-date) ; dynamically scoped, calendar.el does scope this (defvar org-agenda-undo-list nil @@ -5767,22 +5767,22 @@ This function is invoked if `org-agenda-todo-ignore-deadlines', ;; also `european-calendar-style' and use european format (defun org-anniversary (year month day &optional mark) "Like `diary-anniversary', but with fixed (ISO) order of arguments." - (org-no-warnings + (with-no-warnings (let ((calendar-date-style 'european) (european-calendar-style t)) (diary-anniversary day month year mark)))) (defun org-cyclic (N year month day &optional mark) "Like `diary-cyclic', but with fixed (ISO) order of arguments." - (org-no-warnings + (with-no-warnings (let ((calendar-date-style 'european) (european-calendar-style t)) (diary-cyclic N day month year mark)))) (defun org-block (Y1 M1 D1 Y2 M2 D2 &optional mark) "Like `diary-block', but with fixed (ISO) order of arguments." - (org-no-warnings + (with-no-warnings (let ((calendar-date-style 'european) (european-calendar-style t)) (diary-block D1 M1 Y1 D2 M2 Y2 mark)))) (defun org-date (year month day &optional mark) "Like `diary-date', but with fixed (ISO) order of arguments." - (org-no-warnings + (with-no-warnings (let ((calendar-date-style 'european) (european-calendar-style t)) (diary-date day month year mark)))) diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el index 1a82ea847..8d886cdfd 100644 --- a/lisp/org-bbdb.el +++ b/lisp/org-bbdb.el @@ -124,7 +124,7 @@ (declare-function calendar-leap-year-p "calendar" (year)) (declare-function diary-ordinal-suffix "diary-lib" (n)) -(org-no-warnings (defvar date)) ;; unprefixed, from calendar.el +(with-no-warnings (defvar date)) ;; unprefixed, from calendar.el ;; Customization diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 3b449014c..0d61e70ef 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -1566,7 +1566,7 @@ to, overriding the existing value of `org-clock-out-switch-to-state'." ts te s h m remove) (setq org-clock-out-time now) (save-excursion ; Do not replace this with `with-current-buffer'. - (org-no-warnings (set-buffer (org-clocking-buffer))) + (with-no-warnings (set-buffer (org-clocking-buffer))) (save-restriction (widen) (goto-char org-clock-marker) @@ -1711,7 +1711,7 @@ Optional argument N tells to change by that many units." (force-mode-line-update) (error "No active clock")) (save-excursion ; Do not replace this with `with-current-buffer'. - (org-no-warnings (set-buffer (org-clocking-buffer))) + (with-no-warnings (set-buffer (org-clocking-buffer))) (goto-char org-clock-marker) (if (looking-back (concat "^[ \t]*" org-clock-string ".*") (line-beginning-position)) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 1e549cf96..db9c38805 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -630,9 +630,7 @@ Where possible, use the standard interface for changing this line." (defun org-columns-eval (form) (let (hidep) (save-excursion - (beginning-of-line 1) - ;; `next-line' is needed here, because it skips invisible line. - (condition-case nil (org-no-warnings (next-line 1)) (error nil)) + (ignore-errors (move-beginning-of-line 2)) (setq hidep (org-at-heading-p 1))) (eval form) (and hidep (outline-hide-entry)))) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 4df010bb3..7556ca56c 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -94,6 +94,7 @@ (define-obsolete-function-alias 'org-called-interactively-p 'called-interactively-p "Org 9.0") (define-obsolete-function-alias 'org-char-to-string 'char-to-string "Org 9.0") (define-obsolete-function-alias 'org-delete-directory 'delete-directory "Org 9.0") +(define-obsolete-function-alias 'org-no-warnings 'with-no-warnings "Org 9.0") (define-obsolete-function-alias 'org-number-sequence 'number-sequence "Org 9.0") (define-obsolete-function-alias 'org-pop-to-buffer-same-window 'pop-to-buffer-same-window "Org 9.0") (define-obsolete-function-alias 'org-string-match-p 'string-match-p "Org 9.0") diff --git a/lisp/org-macs.el b/lisp/org-macs.el index 762f6b108..e56320e21 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -110,10 +110,6 @@ Otherwise return nil." (goto-char (or ,mpom (point))) ,@body))))) -(defmacro org-no-warnings (&rest body) - (declare (debug (body))) - (cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body)) - (defmacro org-with-remote-undo (buffer &rest body) "Execute BODY while recording undo information in two buffers." (declare (debug (form body)) (indent 1)) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index b2fe310ca..8ff9edfb4 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -221,7 +221,7 @@ this function is called. Otherwise, the current major mode menu is used." (funcall org-mouse-context-menu-function event) (if (fboundp 'mouse-menu-major-mode-map) (popup-menu (mouse-menu-major-mode-map) event prefix) - (org-no-warnings ; don't warn about fallback, obsolete since 23.1 + (with-no-warnings ; don't warn about fallback, obsolete since 23.1 (mouse-major-mode-menu event prefix))))) (setq this-command 'mouse-save-then-kill) (mouse-save-then-kill event))) diff --git a/lisp/org.el b/lisp/org.el index 0534ef9f3..115f15979 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17352,18 +17352,10 @@ DEF-FLAG is t when a double ++ or -- indicates shift relative to The internal representation needed by the calendar is (month day year). This is a wrapper to handle the brain-dead convention in calendar that user function argument order change dependent on argument order." - (if (boundp 'calendar-date-style) - (cond - ((eq calendar-date-style 'american) - (list arg1 arg2 arg3)) - ((eq calendar-date-style 'european) - (list arg2 arg1 arg3)) - ((eq calendar-date-style 'iso) - (list arg2 arg3 arg1))) - (org-no-warnings ;; european-calendar-style is obsolete as of version 23.1 - (if (bound-and-true-p european-calendar-style) - (list arg2 arg1 arg3) - (list arg1 arg2 arg3))))) + (pcase calendar-date-style + (`american (list arg1 arg2 arg3)) + (`european (list arg2 arg1 arg3)) + (`iso (list arg2 arg3 arg1)))) (defun org-eval-in-calendar (form &optional keepdate) "Eval FORM in the calendar window and return to current window. @@ -18202,7 +18194,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays like \"--2d\"." h (string-to-number (match-string 2 s))) (if (org-pos-in-match-range pos 2) (setq h (+ h n)) - (setq n (* dm (org-no-warnings (signum n)))) + (setq n (* dm (with-no-warnings (signum n)))) (unless (= 0 (setq rem (% m dm))) (setq m (+ m (if (> n 0) (- rem) (- dm rem))))) (setq m (+ m n))) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index e2fcb07d3..0bb1dfd6d 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -3107,7 +3107,7 @@ and prefix with \"OrgSrc\". For example, (lambda (style _text-block _text-id _text-begins-block-p) (insert (format "" style)))) (hfy-end-span-handler (lambda () (insert "")))) - (org-no-warnings (htmlfontify-string line)))) + (with-no-warnings (htmlfontify-string line)))) (defun org-odt-do-format-code (code info &optional lang refs retain-labels num-start)