Update personal Lisp files so elint is happy
This commit is contained in:
parent
2972e061a1
commit
7aa17bdfcc
@ -1,23 +1,27 @@
|
||||
;;; buf-manipulation --- Summary
|
||||
;; Some custom functions for buffer content manipulation
|
||||
;;
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(defun delete-current-line ()
|
||||
"Kill the whole line on which point is"
|
||||
"Kill the whole line on which point is."
|
||||
(interactive)
|
||||
|
||||
(beginning-of-line)
|
||||
(kill-line 1))
|
||||
|
||||
(defun copy-func-prototype ()
|
||||
"Copy the current function's prototype to the kill-ring"
|
||||
"Copy the current function's prototype to the kill ring."
|
||||
|
||||
(interactive)
|
||||
|
||||
(save-excursion
|
||||
(beginning-of-defun)
|
||||
(setq protocopy-begin (point))
|
||||
(let ((protocopy-begin (point)))
|
||||
(forward-list)
|
||||
(setq protocopy-end (point))
|
||||
(kill-ring-save protocopy-begin protocopy-end)))
|
||||
(let ((protocopy-end (point)))
|
||||
(kill-ring-save protocopy-begin protocopy-end)))))
|
||||
|
||||
(defun duplicate-line()
|
||||
"Duplicate line at point."
|
||||
@ -29,15 +33,16 @@
|
||||
(kill-line)
|
||||
(yank)
|
||||
(open-line 1)
|
||||
(next-line 1)
|
||||
(forward-line 1)
|
||||
(yank)))
|
||||
|
||||
;; Based on Xah's toggle letter case defun version 2015-12-22
|
||||
;;
|
||||
;; URL: http://ergoemacs.org/emacs/modernization_upcase-word.html
|
||||
(defun toggle-char-case (arg-move-point)
|
||||
"Toggle the case of the char after point. Based on Xah's toggle letter
|
||||
case defun version 2015-12-22
|
||||
"Toggle the case of the char after point.
|
||||
|
||||
URL `http://ergoemacs.org/emacs/modernization_upcase-word.html'
|
||||
Version 2016-02-16"
|
||||
If prefix argument ARG-MOVE-POINT is non-nil, move point after the char."
|
||||
(interactive "P")
|
||||
(let ((case-fold-search nil))
|
||||
(cond
|
||||
@ -88,8 +93,7 @@ Version 2016-02-16"
|
||||
|
||||
; Copied from http://whattheemacsd.com/file-defuns.el-02.html
|
||||
(defun delete-current-buffer-file ()
|
||||
"Removes file connected to current buffer and kills the
|
||||
buffer."
|
||||
"Remove file connected to current buffer and kill the buffer."
|
||||
(interactive)
|
||||
|
||||
(let ((filename (buffer-file-name))
|
||||
@ -102,8 +106,8 @@ Version 2016-02-16"
|
||||
(kill-buffer buffer)
|
||||
(message "File '%s' successfully removed" filename)))))
|
||||
|
||||
; delete-char or close eshell
|
||||
; Copied from https://ryuslash.org/posts/C-d-to-close-eshell.html
|
||||
;; delete-char or close eshell
|
||||
;; Copied from https://ryuslash.org/posts/C-d-to-close-eshell.html
|
||||
(defun eshell-C-d ()
|
||||
"Either call `delete-char' interactively or quit."
|
||||
(interactive)
|
||||
@ -111,7 +115,7 @@ Version 2016-02-16"
|
||||
(condition-case err
|
||||
(call-interactively #'delete-char)
|
||||
(error (if (and (eq (car err) 'end-of-buffer)
|
||||
(looking-back eshell-prompt-regexp))
|
||||
(looking-back eshell-prompt-regexp nil))
|
||||
(kill-buffer)
|
||||
(signal (car err) (cdr err))))))
|
||||
|
||||
@ -119,7 +123,7 @@ Version 2016-02-16"
|
||||
"Kill or copy the whole line point is on.
|
||||
|
||||
If KILL is non-nil, the line gets killed. Otherwise, it gets just
|
||||
copied to the kill-ring."
|
||||
copied to the kill ring."
|
||||
(interactive "P")
|
||||
|
||||
(if kill
|
||||
@ -128,15 +132,20 @@ copied to the kill-ring."
|
||||
(end (progn (end-of-line) (point))))
|
||||
(copy-region-as-kill beginning end))))
|
||||
|
||||
;; Inspired by Bozhidar Batsov's solution:
|
||||
;;
|
||||
;; http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/
|
||||
(defun gpolonkai/move-to-beginning-of-line ()
|
||||
"Move to different beginnings of the line; in order: beginning
|
||||
of the visual line if `visual-line-mode' is active, the first
|
||||
non-whitespace (indentation), the actual beginning of the line.
|
||||
This function will jump between the first character and the
|
||||
indentation if used multiple times.
|
||||
"Move to different beginnings of the line.
|
||||
|
||||
Inspired by Bozhidar Batsov's solution:
|
||||
http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/"
|
||||
These are, in order:
|
||||
|
||||
- beginning of the visual line if `visual-line-mode' is active,
|
||||
- the first non-whitespace (indentation),
|
||||
- the actual beginning of the line.
|
||||
|
||||
This function will jump between the first character and the
|
||||
indentation if used multiple times."
|
||||
(interactive)
|
||||
(let ((last-pos (point)))
|
||||
(when visual-line-mode
|
||||
@ -152,9 +161,10 @@ http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-l
|
||||
(back-to-indentation))))
|
||||
|
||||
(defun gpolonkai/move-to-end-of-line ()
|
||||
"Move to the end of the line. If `visual-line-mode' is active,
|
||||
jump to the end of the visual line first. The jump to the
|
||||
actual end of the line."
|
||||
"Move to the end of the line.
|
||||
|
||||
If `visual-line-mode' is active, jump to the end of the visual
|
||||
line first. Then jump to the actual end of the line."
|
||||
(interactive)
|
||||
(let ((last-pos (point)))
|
||||
(when visual-line-mode
|
||||
@ -167,8 +177,9 @@ http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-l
|
||||
|
||||
(defvar gpolonkai/last-killed-buffer-file-name
|
||||
nil
|
||||
"The last killed buffer. Used by `gpolonkai/kill-this-buffer'
|
||||
and `gpolonkai/undo-buffer-kill'.")
|
||||
"The last killed buffer.
|
||||
|
||||
Used by `gpolonkai/kill-this-buffer' and `gpolonkai/undo-buffer-kill'.")
|
||||
|
||||
(defun gpolonkai/kill-this-buffer ()
|
||||
"Kill the current buffer, but save the buffer file name so it can be undone."
|
||||
@ -177,10 +188,16 @@ http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-l
|
||||
(kill-this-buffer))
|
||||
|
||||
(defun gpolonkai/undo-buffer-kill ()
|
||||
"Undo killing the last buffer. Esentially it visits the file again."
|
||||
"Undo killing the last buffer.
|
||||
|
||||
Esentially it visits the file again."
|
||||
(interactive)
|
||||
(if gpolonkai/last-killed-buffer-file-name
|
||||
(progn
|
||||
(find-file gpolonkai/last-killed-buffer-file-name)
|
||||
(setq gpolonkai/last-killed-buffer-file-name nil))
|
||||
(message "The buffer last killed didn’t visit a file.")))
|
||||
|
||||
(provide 'buf-manipulation)
|
||||
|
||||
;;; buf-manipulation.el ends here
|
||||
|
@ -1,6 +1,13 @@
|
||||
;;; file-manip --- Summary
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(defun open-this-file-as-other-user (user)
|
||||
"Edit current file as USER, using `tramp' and `sudo'. If the current
|
||||
buffer is not visiting a file, prompt for a file name."
|
||||
"Edit current file as USER, using `tramp' and `sudo'.
|
||||
|
||||
If the current buffer is not visiting a file, prompt for a file
|
||||
name."
|
||||
(interactive "sEdit as user (default: root): ")
|
||||
(when (string= "" user)
|
||||
(setq user "root"))
|
||||
@ -22,3 +29,7 @@ buffer is not visiting a file, prompt for a file name."
|
||||
(interactive)
|
||||
(find-file-other-window (concat (file-name-as-directory org-directory)
|
||||
"index.org")))
|
||||
|
||||
(provide 'file-manip)
|
||||
|
||||
;;; file-manip.el ends here
|
||||
|
22
lisp/prog.el
22
lisp/prog.el
@ -1,16 +1,22 @@
|
||||
;;; gp-prog --- Summary
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(defun gpolonkai/prog-in-string-p ()
|
||||
"Return `t' if point is inside a string."
|
||||
"Return t if point is inside a string."
|
||||
(nth 3 (syntax-ppss)))
|
||||
|
||||
(defun gpolonkai/prog-in-comment-p ()
|
||||
"Return `t' if point is inside a comment."
|
||||
"Return t if point is inside a comment."
|
||||
(nth 4 (syntax-ppss)))
|
||||
|
||||
(defun gpolonkai/python-add-docstring ()
|
||||
"Add a Python docstring to the current thing. If point is
|
||||
inside a function, add docstring to that. If point is in a
|
||||
class, add docstring to that. If neither, add docstring to the
|
||||
beginning of the file."
|
||||
"Add a Python docstring to the current thing.
|
||||
|
||||
If point is inside a function, add docstring to that. If point
|
||||
is in a class, add docstring to that. If neither, add docstring
|
||||
to the beginning of the file."
|
||||
(interactive)
|
||||
(save-restriction
|
||||
(widen)
|
||||
@ -35,3 +41,7 @@
|
||||
(open-line-below)
|
||||
(insert "\"\"\"")
|
||||
(open-line-above)))
|
||||
|
||||
(provide 'gp-prog)
|
||||
|
||||
;;; gp-prog.el ends here
|
||||
|
@ -1,15 +1,21 @@
|
||||
;;; package --- Summary
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
(defun org-space-key (&optional arg)
|
||||
"Insert two spaces after a period."
|
||||
"Insert two spaces after a period.
|
||||
|
||||
ARG will be passed down verbatim to `self-insert-command'"
|
||||
(interactive "p")
|
||||
|
||||
(when (looking-back "[.!?…]")
|
||||
(when (looking-back "[.!?…]" nil)
|
||||
(call-interactively 'self-insert-command arg))
|
||||
(call-interactively 'self-insert-command arg))
|
||||
|
||||
;; From http://pages.sachachua.com/.emacs.d/Sacha.html
|
||||
(defun sachachua/fill-or-unfill-paragraph (&optional unfill region)
|
||||
"Fill paragraph (or REGION).
|
||||
With the prefix argument UNFILL, unfill it instead."
|
||||
"Fill (or unfill, if UNFILL is non-nil) paragraph (or REGION)."
|
||||
(interactive (progn
|
||||
(barf-if-buffer-read-only)
|
||||
(list (if current-prefix-arg 'unfill) t)))
|
||||
@ -20,7 +26,9 @@
|
||||
(defun so/query-swap-strings (from-string
|
||||
to-string
|
||||
&optional delimited start end)
|
||||
"Swap occurrences of FROM-STRING and TO-STRING."
|
||||
"Swap occurrences of FROM-STRING and TO-STRING.
|
||||
|
||||
DELIMITED, START, and END are passed down verbatim to `perform-replace'."
|
||||
(interactive
|
||||
(let ((common
|
||||
(query-replace-read-args
|
||||
@ -40,3 +48,7 @@
|
||||
,to-string
|
||||
,from-string))
|
||||
t t delimited nil nil start end))
|
||||
|
||||
(provide 'text-manip)
|
||||
|
||||
;;; text-manip.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user