Move Magit related functions from configuration.org to lisp/gpolonkai/magit-utils.el
This commit is contained in:
parent
7502d37992
commit
3bd5c2c865
@ -1,57 +1,3 @@
|
|||||||
* Custom functions and commands
|
|
||||||
|
|
||||||
This is a collection of functions and commands i wrote or stole from all around the internet.
|
|
||||||
|
|
||||||
** Magit
|
|
||||||
|
|
||||||
*** Go to the beginning of the current section
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(defun gpolonkai/magit-goto-beginning-of-section ()
|
|
||||||
(interactive)
|
|
||||||
(let ((section (magit-current-section)))
|
|
||||||
(magit-section-goto section)))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Go to the end of the current section
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
|
|
||||||
(defun gpolonkai/magit-goto-end-of-section ()
|
|
||||||
"Move to the beginning of the next visible section."
|
|
||||||
(interactive)
|
|
||||||
(unless (eobp)
|
|
||||||
(let ((section (magit-current-section)))
|
|
||||||
(if (oref section parent)
|
|
||||||
(let ((next (and (not (oref section hidden))
|
|
||||||
(not (= (oref section end)
|
|
||||||
(1+ (point))))
|
|
||||||
(car (oref section children)))))
|
|
||||||
(while (and section (not next))
|
|
||||||
(unless (setq next (car (magit-section-siblings section 'next)))
|
|
||||||
(setq section (oref section parent))))
|
|
||||||
(if next
|
|
||||||
(magit-section-goto next)
|
|
||||||
(end-of-buffer)))
|
|
||||||
(magit-section-goto 1)))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Find the first URL in the current section
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(defun gpolonkai/magit-find-first-link ()
|
|
||||||
(interactive)
|
|
||||||
(let ((bos (save-excursion
|
|
||||||
(gpolonkai/magit-goto-beginning-of-section)
|
|
||||||
(point)))
|
|
||||||
(eos (save-excursion
|
|
||||||
(gpolonkai/magit-goto-end-of-section)
|
|
||||||
(point))))
|
|
||||||
(goto-char bos)
|
|
||||||
(when (re-search-forward "https?://" eos t)
|
|
||||||
(goto-char (match-beginning 0)))))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Set up the very basics
|
* Set up the very basics
|
||||||
|
|
||||||
Now that we have package management configured we can set up defaults more easily. This includes every builtin packages, font faces, and the like.
|
Now that we have package management configured we can set up defaults more easily. This includes every builtin packages, font faces, and the like.
|
||||||
|
1
init.el
1
init.el
@ -63,6 +63,7 @@
|
|||||||
(load "gpolonkai/text-utils")
|
(load "gpolonkai/text-utils")
|
||||||
(load "gpolonkai/nav-utils")
|
(load "gpolonkai/nav-utils")
|
||||||
(load "gpolonkai/file-utils")
|
(load "gpolonkai/file-utils")
|
||||||
|
(load "gpolonkai/magit-utils")
|
||||||
|
|
||||||
;; I started moving my configuration to this Org file. It’s easier to document this way.
|
;; I started moving my configuration to this Org file. It’s easier to document this way.
|
||||||
(org-babel-load-file (expand-file-name "configuration.org" user-emacs-directory))
|
(org-babel-load-file (expand-file-name "configuration.org" user-emacs-directory))
|
||||||
|
65
lisp/gpolonkai/magit-utils.el
Normal file
65
lisp/gpolonkai/magit-utils.el
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
;;; gpolonkai/magit-utils.el --- Magit related utilities
|
||||||
|
;;;
|
||||||
|
;;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
;;; Copyright © 2025 Gergely Polonkai
|
||||||
|
;;; This library is free software; you can redistribute it and/or
|
||||||
|
;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
;;; License as published by the Free Software Foundation; either
|
||||||
|
;;; version 3 of the License, or (at your option) any later version.
|
||||||
|
;;;
|
||||||
|
;;; This library is distributed in the hope that it will be useful,
|
||||||
|
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
;;; Lesser General Public License for more details.
|
||||||
|
;;;
|
||||||
|
;;; You should have received a copy of the GNU Lesser General Public
|
||||||
|
;;; License along with this library; if not, write to the
|
||||||
|
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
;;; Boston, MA 02111-1307, USA.
|
||||||
|
;;;
|
||||||
|
;;; Commentary:
|
||||||
|
;;;
|
||||||
|
;;; Utility functions stolen from the Internet or written by me
|
||||||
|
;;;
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(defun gpolonkai/magit-goto-beginning-of-section ()
|
||||||
|
"Go to the beginning of the current Magit section."
|
||||||
|
(interactive)
|
||||||
|
(let ((section (magit-current-section)))
|
||||||
|
(magit-section-goto section)))
|
||||||
|
|
||||||
|
(defun gpolonkai/magit-goto-end-of-section ()
|
||||||
|
"Move to the beginning of the next visible section."
|
||||||
|
(interactive)
|
||||||
|
(unless (eobp)
|
||||||
|
(let ((section (magit-current-section)))
|
||||||
|
(if (oref section parent)
|
||||||
|
(let ((next (and (not (oref section hidden))
|
||||||
|
(not (= (oref section end)
|
||||||
|
(1+ (point))))
|
||||||
|
(car (oref section children)))))
|
||||||
|
(while (and section (not next))
|
||||||
|
(unless (setq next (car (magit-section-siblings section 'next)))
|
||||||
|
(setq section (oref section parent))))
|
||||||
|
(if next
|
||||||
|
(magit-section-goto next)
|
||||||
|
(end-of-buffer)))
|
||||||
|
(magit-section-goto 1)))))
|
||||||
|
|
||||||
|
(defun gpolonkai/magit-find-first-link ()
|
||||||
|
"Find the first URL in the current section."
|
||||||
|
(interactive)
|
||||||
|
(let ((bos (save-excursion
|
||||||
|
(gpolonkai/magit-goto-beginning-of-section)
|
||||||
|
(point)))
|
||||||
|
(eos (save-excursion
|
||||||
|
(gpolonkai/magit-goto-end-of-section)
|
||||||
|
(point))))
|
||||||
|
(goto-char bos)
|
||||||
|
(when (re-search-forward "https?://" eos t)
|
||||||
|
(goto-char (match-beginning 0)))))
|
||||||
|
|
||||||
|
(provide 'gpolonkai/magit-utils)
|
||||||
|
|
||||||
|
;;; magit-utils.el ends here
|
Loading…
x
Reference in New Issue
Block a user