Limit lines to 80 chars
And fix comment indentation. Vertically aligned comments in function definitions, indents them in the help buffer.
This commit is contained in:
parent
08cd88a6ea
commit
556433f95c
|
@ -189,8 +189,7 @@ automatically applied to."
|
||||||
|
|
||||||
(defun spacemacs/swap-windows (window1 window2)
|
(defun spacemacs/swap-windows (window1 window2)
|
||||||
"Swap two windows.
|
"Swap two windows.
|
||||||
WINDOW1 and WINDOW2 must be valid windows. They may contain child
|
WINDOW1 and WINDOW2 must be valid windows. They may contain child windows."
|
||||||
windows."
|
|
||||||
(let ((state1 (window-state-get window1))
|
(let ((state1 (window-state-get window1))
|
||||||
(state2 (window-state-get window2)))
|
(state2 (window-state-get window2)))
|
||||||
;; to put state into dedicated windows, we must undedicate them first (not
|
;; to put state into dedicated windows, we must undedicate them first (not
|
||||||
|
@ -250,8 +249,7 @@ Dedicated (locked) windows are left untouched."
|
||||||
|
|
||||||
(defun spacemacs/move-buffer-to-window (windownum follow-focus-p)
|
(defun spacemacs/move-buffer-to-window (windownum follow-focus-p)
|
||||||
"Moves a buffer to a window, using the spacemacs numbering. follow-focus-p
|
"Moves a buffer to a window, using the spacemacs numbering. follow-focus-p
|
||||||
controls whether focus moves to new window (with buffer), or stays on
|
controls whether focus moves to new window (with buffer), or stays on current"
|
||||||
current"
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((b (current-buffer))
|
(let ((b (current-buffer))
|
||||||
(w1 (selected-window))
|
(w1 (selected-window))
|
||||||
|
@ -264,8 +262,8 @@ Dedicated (locked) windows are left untouched."
|
||||||
|
|
||||||
(defun spacemacs/swap-buffers-to-window (windownum follow-focus-p)
|
(defun spacemacs/swap-buffers-to-window (windownum follow-focus-p)
|
||||||
"Swaps visible buffers between active window and selected window.
|
"Swaps visible buffers between active window and selected window.
|
||||||
follow-focus-p controls whether focus moves to new window (with buffer), or
|
follow-focus-p controls whether focus moves to new window (with buffer), or
|
||||||
stays on current"
|
stays on current"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((b1 (current-buffer))
|
(let* ((b1 (current-buffer))
|
||||||
(w1 (selected-window))
|
(w1 (selected-window))
|
||||||
|
@ -527,8 +525,8 @@ If the universal prefix argument is used then will the windows too."
|
||||||
;; from http://dfan.org/blog/2009/02/19/emacs-dedicated-windows/
|
;; from http://dfan.org/blog/2009/02/19/emacs-dedicated-windows/
|
||||||
(defun spacemacs/toggle-current-window-dedication ()
|
(defun spacemacs/toggle-current-window-dedication ()
|
||||||
"Toggle dedication state of a window. Commands that change the buffer that a
|
"Toggle dedication state of a window. Commands that change the buffer that a
|
||||||
window is displaying will not typically change the buffer displayed by
|
window is displaying will not typically change the buffer displayed by
|
||||||
a dedicated window."
|
a dedicated window."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((window (selected-window))
|
(let* ((window (selected-window))
|
||||||
(dedicated (window-dedicated-p window)))
|
(dedicated (window-dedicated-p window)))
|
||||||
|
@ -543,9 +541,9 @@ If the universal prefix argument is used then will the windows too."
|
||||||
(defun spacemacs--directory-path ()
|
(defun spacemacs--directory-path ()
|
||||||
"Retrieve the directory path of the current buffer.
|
"Retrieve the directory path of the current buffer.
|
||||||
|
|
||||||
If the buffer is not visiting a file, use the `list-buffers-directory'
|
If the buffer is not visiting a file, use the `list-buffers-directory' variable
|
||||||
variable as a fallback to display the directory, useful in buffers like the
|
as a fallback to display the directory, useful in buffers like the ones created
|
||||||
ones created by `magit' and `dired'.
|
by `magit' and `dired'.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
- A string containing the directory path in case of success.
|
- A string containing the directory path in case of success.
|
||||||
|
@ -574,7 +572,8 @@ Returns:
|
||||||
(concat file-path ":" (number-to-string (line-number-at-pos)))))
|
(concat file-path ":" (number-to-string (line-number-at-pos)))))
|
||||||
|
|
||||||
(defun spacemacs--file-path-with-line-column ()
|
(defun spacemacs--file-path-with-line-column ()
|
||||||
"Retrieve the file path of the current buffer, including line and column number.
|
"Retrieve the file path of the current buffer,
|
||||||
|
including line and column number.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
- A string containing the file path in case of success.
|
- A string containing the file path in case of success.
|
||||||
|
@ -584,8 +583,8 @@ Returns:
|
||||||
file-path
|
file-path
|
||||||
":"
|
":"
|
||||||
(number-to-string (if (and
|
(number-to-string (if (and
|
||||||
;; Emacs 26 introduced this variable.
|
;; Emacs 26 introduced this variable. Remove this
|
||||||
;; Remove this check once 26 becomes the minimum version.
|
;; check once 26 becomes the minimum version.
|
||||||
(boundp column-number-indicator-zero-based)
|
(boundp column-number-indicator-zero-based)
|
||||||
(not column-number-indicator-zero-based))
|
(not column-number-indicator-zero-based))
|
||||||
(1+ (current-column))
|
(1+ (current-column))
|
||||||
|
@ -642,7 +641,8 @@ buffer."
|
||||||
(message "WARNING: Current buffer is not attached to a file!")))
|
(message "WARNING: Current buffer is not attached to a file!")))
|
||||||
|
|
||||||
(defun spacemacs/copy-file-path-with-line-column ()
|
(defun spacemacs/copy-file-path-with-line-column ()
|
||||||
"Copy and show the file path of the current buffer, including line and column number.
|
"Copy and show the file path of the current buffer,
|
||||||
|
including line and column number.
|
||||||
|
|
||||||
This function respects the value of the `column-number-indicator-zero-based'
|
This function respects the value of the `column-number-indicator-zero-based'
|
||||||
variable."
|
variable."
|
||||||
|
@ -775,9 +775,10 @@ in a new frame."
|
||||||
"Prefixes for windows that are not deleted when changing split layout.
|
"Prefixes for windows that are not deleted when changing split layout.
|
||||||
|
|
||||||
You can add an entry here by using the following:
|
You can add an entry here by using the following:
|
||||||
(add-to-list 'spacemacs-window-split-ignore-prefixes \"Buffer prefix\")")
|
(add-to-list 'spacemacs-window-split-ignore-prefixes \"Buffer prefix\")")
|
||||||
|
|
||||||
(defvar spacemacs-window-split-delete-function 'spacemacs/window-split-default-delete
|
(defvar spacemacs-window-split-delete-function
|
||||||
|
'spacemacs/window-split-default-delete
|
||||||
"Function used to delete other windows when changing layout.
|
"Function used to delete other windows when changing layout.
|
||||||
|
|
||||||
Used as a callback by the following functions:
|
Used as a callback by the following functions:
|
||||||
|
@ -798,11 +799,12 @@ Possible values:
|
||||||
(defun spacemacs/window-split-grid (&optional purge)
|
(defun spacemacs/window-split-grid (&optional purge)
|
||||||
"Set the layout to a 2x2 grid.
|
"Set the layout to a 2x2 grid.
|
||||||
|
|
||||||
Uses the funcion defined in `spacemacs-window-split-delete-function' as a means to
|
Uses the funcion defined in `spacemacs-window-split-delete-function'
|
||||||
remove windows.
|
as a means to remove windows.
|
||||||
|
|
||||||
When called with a prefix argument, it uses `delete-other-windows' as a means
|
When called with a prefix argument, it uses `delete-other-windows'
|
||||||
to remove windows, regardless of the value in `spacemacs-window-split-delete-function'."
|
as a means to remove windows, regardless of the value in
|
||||||
|
`spacemacs-window-split-delete-function'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if purge
|
(if purge
|
||||||
(let ((ignore-window-parameters t))
|
(let ((ignore-window-parameters t))
|
||||||
|
@ -823,11 +825,12 @@ to remove windows, regardless of the value in `spacemacs-window-split-delete-fun
|
||||||
(defun spacemacs/window-split-triple-columns (&optional purge)
|
(defun spacemacs/window-split-triple-columns (&optional purge)
|
||||||
"Set the layout to triple columns.
|
"Set the layout to triple columns.
|
||||||
|
|
||||||
Uses the funcion defined in `spacemacs-window-split-delete-function' as a means to
|
Uses the funcion defined in `spacemacs-window-split-delete-function'
|
||||||
remove windows.
|
as a means to remove windows.
|
||||||
|
|
||||||
When called with a prefix argument, it uses `delete-other-windows' as a means
|
When called with a prefix argument, it uses `delete-other-windows'
|
||||||
to remove windows, regardless of the value in `spacemacs-window-split-delete-function'."
|
as a means to remove windows, regardless of the value in
|
||||||
|
`spacemacs-window-split-delete-function'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if purge
|
(if purge
|
||||||
(let ((ignore-window-parameters t))
|
(let ((ignore-window-parameters t))
|
||||||
|
@ -846,11 +849,12 @@ to remove windows, regardless of the value in `spacemacs-window-split-delete-fun
|
||||||
(defun spacemacs/window-split-double-columns (&optional purge)
|
(defun spacemacs/window-split-double-columns (&optional purge)
|
||||||
"Set the layout to double columns.
|
"Set the layout to double columns.
|
||||||
|
|
||||||
Uses the funcion defined in `spacemacs-window-split-delete-function' as a means to
|
Uses the funcion defined in `spacemacs-window-split-delete-function'
|
||||||
remove windows.
|
as a means to remove windows.
|
||||||
|
|
||||||
When called with a prefix argument, it uses `delete-other-windows' as a means
|
When called with a prefix argument, it uses `delete-other-windows'
|
||||||
to remove windows, regardless of the value in `spacemacs-window-split-delete-function'."
|
as a means to remove windows, regardless of the value in
|
||||||
|
`spacemacs-window-split-delete-function'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if purge
|
(if purge
|
||||||
(let ((ignore-window-parameters t))
|
(let ((ignore-window-parameters t))
|
||||||
|
@ -858,19 +862,21 @@ to remove windows, regardless of the value in `spacemacs-window-split-delete-fun
|
||||||
(funcall spacemacs-window-split-delete-function))
|
(funcall spacemacs-window-split-delete-function))
|
||||||
(if (spacemacs--window-split-splittable-windows)
|
(if (spacemacs--window-split-splittable-windows)
|
||||||
(let* ((previous-files (seq-filter #'buffer-file-name
|
(let* ((previous-files (seq-filter #'buffer-file-name
|
||||||
(delq (current-buffer) (buffer-list)))))
|
(delq (current-buffer) (buffer-list)))))
|
||||||
(set-window-buffer (split-window-right) (or (car previous-files) "*scratch*"))
|
(set-window-buffer (split-window-right)
|
||||||
|
(or (car previous-files) "*scratch*"))
|
||||||
(balance-windows))
|
(balance-windows))
|
||||||
(message "There are no main windows available to split!")))
|
(message "There are no main windows available to split!")))
|
||||||
|
|
||||||
(defun spacemacs/window-split-single-column (&optional purge)
|
(defun spacemacs/window-split-single-column (&optional purge)
|
||||||
"Set the layout to single column.
|
"Set the layout to single column.
|
||||||
|
|
||||||
Uses the funcion defined in `spacemacs-window-split-delete-function' as a means to
|
Uses the funcion defined in `spacemacs-window-split-delete-function'
|
||||||
remove windows.
|
as a means to remove windows.
|
||||||
|
|
||||||
When called with a prefix argument, it uses `delete-other-windows' as a means
|
When called with a prefix argument, it uses `delete-other-windows'
|
||||||
to remove windows, regardless of the value in `spacemacs-window-split-delete-function'."
|
as a means to remove windows, regardless of the value in
|
||||||
|
`spacemacs-window-split-delete-function'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(if purge
|
(if purge
|
||||||
(let ((ignore-window-parameters t))
|
(let ((ignore-window-parameters t))
|
||||||
|
@ -1008,18 +1014,18 @@ toggling fullscreen."
|
||||||
|
|
||||||
(defun spacemacs/toggle-frame-fullscreen-non-native ()
|
(defun spacemacs/toggle-frame-fullscreen-non-native ()
|
||||||
"Toggle full screen non-natively. Uses the `fullboth' frame paramerter
|
"Toggle full screen non-natively. Uses the `fullboth' frame paramerter
|
||||||
rather than `fullscreen'. Useful to fullscreen on OSX w/o animations."
|
rather than `fullscreen'. Useful to fullscreen on OSX w/o animations."
|
||||||
(interactive)
|
(interactive)
|
||||||
(modify-frame-parameters
|
(modify-frame-parameters
|
||||||
nil
|
nil
|
||||||
`((maximized
|
`((maximized
|
||||||
. ,(unless (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
|
. ,(unless (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
|
||||||
(frame-parameter nil 'fullscreen)))
|
(frame-parameter nil 'fullscreen)))
|
||||||
(fullscreen
|
(fullscreen
|
||||||
. ,(if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
|
. ,(if (memq (frame-parameter nil 'fullscreen) '(fullscreen fullboth))
|
||||||
(if (eq (frame-parameter nil 'maximized) 'maximized)
|
(if (eq (frame-parameter nil 'maximized) 'maximized)
|
||||||
'maximized)
|
'maximized)
|
||||||
'fullboth)))))
|
'fullboth)))))
|
||||||
|
|
||||||
(defun spacemacs/safe-revert-buffer ()
|
(defun spacemacs/safe-revert-buffer ()
|
||||||
"Prompt before reverting the file."
|
"Prompt before reverting the file."
|
||||||
|
@ -1049,7 +1055,8 @@ toggling fullscreen."
|
||||||
(defun spacemacs//open-in-external-app (file-path)
|
(defun spacemacs//open-in-external-app (file-path)
|
||||||
"Open `file-path' in external application."
|
"Open `file-path' in external application."
|
||||||
(cond
|
(cond
|
||||||
((spacemacs/system-is-mswindows) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\\\" file-path)))
|
((spacemacs/system-is-mswindows)
|
||||||
|
(w32-shell-execute "open" (replace-regexp-in-string "/" "\\\\" file-path)))
|
||||||
((spacemacs/system-is-mac) (shell-command (format "open \"%s\"" file-path)))
|
((spacemacs/system-is-mac) (shell-command (format "open \"%s\"" file-path)))
|
||||||
((spacemacs/system-is-linux) (let ((process-connection-type nil))
|
((spacemacs/system-is-linux) (let ((process-connection-type nil))
|
||||||
(start-process "" nil "xdg-open" file-path)))))
|
(start-process "" nil "xdg-open" file-path)))))
|
||||||
|
@ -1186,13 +1193,14 @@ With negative N, comment out original line and use the absolute value."
|
||||||
(buffer-substring (region-beginning) (region-end))
|
(buffer-substring (region-beginning) (region-end))
|
||||||
(prog1 (thing-at-point 'line)
|
(prog1 (thing-at-point 'line)
|
||||||
(end-of-line)
|
(end-of-line)
|
||||||
(if (< 0 (forward-line 1)) ; Go to beginning of next line, or make a new one
|
;; Go to beginning of next line, or make a new one
|
||||||
|
(if (< 0 (forward-line 1))
|
||||||
(newline))))))
|
(newline))))))
|
||||||
(dotimes (i (abs (or n 1))) ; Insert N times, or once if not specified
|
(dotimes (i (abs (or n 1))) ; Insert N times, or once if not specified
|
||||||
(insert text))))
|
(insert text))))
|
||||||
(if use-region nil ; Only if we're working with a line (not a region)
|
(if use-region nil ; Only if we're working with a line (not a region)
|
||||||
(let ((pos (- (point) (line-beginning-position)))) ; Save column
|
(let ((pos (- (point) (line-beginning-position)))) ; Save column
|
||||||
(if (> 0 n) ; Comment out original with negative arg
|
(if (> 0 n) ; Comment out original with negative arg
|
||||||
(comment-region (line-beginning-position) (line-end-position)))
|
(comment-region (line-beginning-position) (line-end-position)))
|
||||||
(forward-line 1)
|
(forward-line 1)
|
||||||
(forward-char pos)))))
|
(forward-char pos)))))
|
||||||
|
@ -1237,7 +1245,8 @@ A non-nil argument sorts in REVERSE order."
|
||||||
(>= (1+ (- (line-number-at-pos (region-end))
|
(>= (1+ (- (line-number-at-pos (region-end))
|
||||||
(line-number-at-pos (region-beginning)))) 2))
|
(line-number-at-pos (region-beginning)))) 2))
|
||||||
(sort-columns reverse (region-beginning) (region-end))
|
(sort-columns reverse (region-beginning) (region-end))
|
||||||
(error "Sorting by column requires a block/rect selection on 2 or more lines.")))
|
(error
|
||||||
|
"Sorting by column requires a block/rect selection on 2 or more lines.")))
|
||||||
|
|
||||||
(defun spacemacs/sort-lines-by-column-reverse ()
|
(defun spacemacs/sort-lines-by-column-reverse ()
|
||||||
"Sort lines by the selected column in reverse order,
|
"Sort lines by the selected column in reverse order,
|
||||||
|
@ -1462,7 +1471,8 @@ Decision is based on `dotspacemacs-line-numbers'."
|
||||||
Decision is based on `dotspacemacs-line-numbers'."
|
Decision is based on `dotspacemacs-line-numbers'."
|
||||||
(or (eq dotspacemacs-line-numbers 'relative)
|
(or (eq dotspacemacs-line-numbers 'relative)
|
||||||
(and (listp dotspacemacs-line-numbers)
|
(and (listp dotspacemacs-line-numbers)
|
||||||
(car (spacemacs/mplist-get-values dotspacemacs-line-numbers :relative)))))
|
(car (spacemacs/mplist-get-values dotspacemacs-line-numbers
|
||||||
|
:relative)))))
|
||||||
|
|
||||||
(defun spacemacs/visual-line-numbers-p ()
|
(defun spacemacs/visual-line-numbers-p ()
|
||||||
"Return non-nil if line numbers should be visual.
|
"Return non-nil if line numbers should be visual.
|
||||||
|
@ -1507,19 +1517,23 @@ Decision is based on `dotspacemacs-line-numbers'."
|
||||||
(defun spacemacs//linum-curent-buffer-is-not-too-big ()
|
(defun spacemacs//linum-curent-buffer-is-not-too-big ()
|
||||||
"Return non-nil if buffer size is not too big."
|
"Return non-nil if buffer size is not too big."
|
||||||
(not (and (listp dotspacemacs-line-numbers)
|
(not (and (listp dotspacemacs-line-numbers)
|
||||||
(spacemacs/mplist-get-values dotspacemacs-line-numbers :size-limit-kb)
|
(spacemacs/mplist-get-values dotspacemacs-line-numbers
|
||||||
|
:size-limit-kb)
|
||||||
(> (buffer-size)
|
(> (buffer-size)
|
||||||
(* 1000 (car (spacemacs/mplist-get-values dotspacemacs-line-numbers
|
(* 1000
|
||||||
:size-limit-kb)))))))
|
(car (spacemacs/mplist-get-values dotspacemacs-line-numbers
|
||||||
|
:size-limit-kb)))))))
|
||||||
|
|
||||||
;; see tests in tests/layers/+distribution/spacemacs-base/line-numbers-utest.el
|
;; see tests in tests/layers/+distribution/spacemacs-base/line-numbers-utest.el
|
||||||
;; for the different possible cases
|
;; for the different possible cases
|
||||||
(defun spacemacs//linum-enabled-for-current-major-mode ()
|
(defun spacemacs//linum-enabled-for-current-major-mode ()
|
||||||
"Return non-nil if line number is enabled for current major-mode."
|
"Return non-nil if line number is enabled for current major-mode."
|
||||||
(let* ((disabled-for-modes (spacemacs/mplist-get-values dotspacemacs-line-numbers
|
(let* ((disabled-for-modes
|
||||||
:disabled-for-modes))
|
(spacemacs/mplist-get-values dotspacemacs-line-numbers
|
||||||
(user-enabled-for-modes (spacemacs/mplist-get-values dotspacemacs-line-numbers
|
:disabled-for-modes))
|
||||||
:enabled-for-modes))
|
(user-enabled-for-modes
|
||||||
|
(spacemacs/mplist-get-values dotspacemacs-line-numbers
|
||||||
|
:enabled-for-modes))
|
||||||
;; default `enabled-for-modes' to '(prog-mode text-mode), because it is
|
;; default `enabled-for-modes' to '(prog-mode text-mode), because it is
|
||||||
;; a more sensible default than enabling in all buffers - including
|
;; a more sensible default than enabling in all buffers - including
|
||||||
;; Magit buffers, terminal buffers, etc. But don't include prog-mode or
|
;; Magit buffers, terminal buffers, etc. But don't include prog-mode or
|
||||||
|
@ -1548,4 +1562,3 @@ Decision is based on `dotspacemacs-line-numbers'."
|
||||||
enabled-for-parent ; mode is one of default allowed modes
|
enabled-for-parent ; mode is one of default allowed modes
|
||||||
disabled-for-modes
|
disabled-for-modes
|
||||||
(not disabled-for-parent)))))
|
(not disabled-for-parent)))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue