reorder the file to fix byte-compiler warnings
This commit is contained in:
parent
0f98e4566b
commit
84de252877
83
winum.el
83
winum.el
|
@ -35,21 +35,24 @@
|
||||||
;; with some ideas and code taken from https://github.com/abo-abo/ace-window.
|
;; with some ideas and code taken from https://github.com/abo-abo/ace-window.
|
||||||
;;
|
;;
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
;;
|
||||||
;; FIXME: Error during redisplay: (eval (winum-get-number-string)) signaled
|
;; FIXME: Error during redisplay: (eval (winum-get-number-string)) signaled
|
||||||
;; (wrong-type-argument numberp nil) when opening a helm buffer.
|
;; (wrong-type-argument numberp nil) when opening a helm buffer.
|
||||||
|
;;
|
||||||
|
|
||||||
(eval-when-compile (require 'cl-lib))
|
(eval-when-compile (require 'cl-lib))
|
||||||
|
|
||||||
|
;; Configuration variables -----------------------------------------------------
|
||||||
|
|
||||||
(defgroup winum nil
|
(defgroup winum nil
|
||||||
"Navigate and manage windows using numbers."
|
"Navigate and manage windows using numbers."
|
||||||
:group 'convenience)
|
:group 'convenience)
|
||||||
|
|
||||||
;; FIXME: when changed from frame-local to non-local in customize, need to
|
|
||||||
;; force update or `winum-get-number' fails and messes the
|
|
||||||
;; modeline until next update.
|
|
||||||
(defcustom winum-scope 'global
|
(defcustom winum-scope 'global
|
||||||
"Frames affected by a number set."
|
"Frames affected by a number set."
|
||||||
|
;; FIXME: when changed from frame-local to non-local in customize, need to
|
||||||
|
;; force update or `winum-get-number' fails and messes the
|
||||||
|
;; modeline until next update.
|
||||||
:group 'winum
|
:group 'winum
|
||||||
:type '(choice
|
:type '(choice
|
||||||
(const :tag "frame local" frame-local)
|
(const :tag "frame local" frame-local)
|
||||||
|
@ -118,6 +121,42 @@ numbers in the mode-line.")
|
||||||
map)
|
map)
|
||||||
"Keymap used for `winum-mode'.")
|
"Keymap used for `winum-mode'.")
|
||||||
|
|
||||||
|
;; Internal variables ----------------------------------------------------------
|
||||||
|
|
||||||
|
(defvar winum--max-frames 16
|
||||||
|
"Maximum number of frames that can be numbered.")
|
||||||
|
|
||||||
|
(defvar winum--window-count nil
|
||||||
|
"Current count of windows to be numbered.")
|
||||||
|
|
||||||
|
(defvar winum--remaining nil
|
||||||
|
"A list of window numbers to assign.")
|
||||||
|
|
||||||
|
(defvar winum--window-vector nil
|
||||||
|
"Vector of windows indexed by their number.
|
||||||
|
Used internally by winum to get a window provided a number.")
|
||||||
|
|
||||||
|
(defvar winum--numbers-table nil
|
||||||
|
"Hash table of numbers indexed by their window.
|
||||||
|
Used internally by winum to get a number provided a window.")
|
||||||
|
|
||||||
|
(defvar winum--frames-table nil
|
||||||
|
"Table linking windows to numbers and numbers to windows for each frame.
|
||||||
|
|
||||||
|
Used only when `winum-scope' is 'frame-local to keep track of
|
||||||
|
separate window numbers sets in every frame.
|
||||||
|
|
||||||
|
It is a hash table using Emacs frames as keys and cons of the form
|
||||||
|
\(`winum--window-vector' . `winum--numbers-table')
|
||||||
|
as values.
|
||||||
|
|
||||||
|
To get a window given a number, use the `car' of a value.
|
||||||
|
To get a number given a window, use the `cdr' of a value.
|
||||||
|
|
||||||
|
Such a structure allows for per-frame bidirectional fast access.")
|
||||||
|
|
||||||
|
;; Interactive functions -------------------------------------------------------
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(define-minor-mode winum-mode
|
(define-minor-mode winum-mode
|
||||||
"A minor mode that allows for managing windows based on window numbers."
|
"A minor mode that allows for managing windows based on window numbers."
|
||||||
|
@ -241,6 +280,8 @@ There are several ways to provide the number:
|
||||||
(winum--switch-to-window w))
|
(winum--switch-to-window w))
|
||||||
(error "No window numbered %d" n))))
|
(error "No window numbered %d" n))))
|
||||||
|
|
||||||
|
;; Public API ------------------------------------------------------------------
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun winum-get-window-by-number (n)
|
(defun winum-get-window-by-number (n)
|
||||||
"Return window numbered N if exists, nil otherwise."
|
"Return window numbered N if exists, nil otherwise."
|
||||||
|
@ -273,39 +314,7 @@ WINDOW: if specified, the window of which we want to know the number.
|
||||||
(gethash w (cdr (gethash (selected-frame) winum--frames-table)))
|
(gethash w (cdr (gethash (selected-frame) winum--frames-table)))
|
||||||
(gethash w winum--numbers-table))))
|
(gethash w winum--numbers-table))))
|
||||||
|
|
||||||
;; Implementation
|
;; Internal functions ----------------------------------------------------------
|
||||||
|
|
||||||
(defvar winum--max-frames 16
|
|
||||||
"Maximum number of frames that can be numbered.")
|
|
||||||
|
|
||||||
(defvar winum--window-count nil
|
|
||||||
"Current count of windows to be numbered.")
|
|
||||||
|
|
||||||
(defvar winum--remaining nil
|
|
||||||
"A list of window numbers to assign.")
|
|
||||||
|
|
||||||
(defvar winum--window-vector nil
|
|
||||||
"Vector of windows indexed by their number.
|
|
||||||
Used internally by winum to get a window provided a number.")
|
|
||||||
|
|
||||||
(defvar winum--numbers-table nil
|
|
||||||
"Hash table of numbers indexed by their window.
|
|
||||||
Used internally by winum to get a number provided a window.")
|
|
||||||
|
|
||||||
(defvar winum--frames-table nil
|
|
||||||
"Table linking windows to numbers and numbers to windows for each frame.
|
|
||||||
|
|
||||||
Used only when `winum-scope' is 'frame-local to keep track of
|
|
||||||
separate window numbers sets in every frame.
|
|
||||||
|
|
||||||
It is a hash table using Emacs frames as keys and cons of the form
|
|
||||||
\(`winum--window-vector' . `winum--numbers-table')
|
|
||||||
as values.
|
|
||||||
|
|
||||||
To get a window given a number, use the `car' of a value.
|
|
||||||
To get a number given a window, use the `cdr' of a value.
|
|
||||||
|
|
||||||
Such a structure allows for per-frame bidirectional fast access.")
|
|
||||||
|
|
||||||
(defun winum--init ()
|
(defun winum--init ()
|
||||||
"Initialize winum-mode."
|
"Initialize winum-mode."
|
||||||
|
|
Loading…
Reference in a new issue