diff options
Diffstat (limited to '')
-rw-r--r-- | emacs/elisp/my-buffers.el | 39 | ||||
-rw-r--r-- | emacs/elisp/my-git-extra.el | 50 | ||||
-rw-r--r-- | emacs/elisp/my-packages-extra.el | 65 | ||||
-rw-r--r-- | emacs/elisp/my-strings.el | 23 | ||||
-rw-r--r-- | emacs/elisp/my-web.el | 32 | ||||
-rw-r--r-- | emacs/elisp/my-work.el | 21 | ||||
-rw-r--r-- | lisp/my-cheeseboard.el (renamed from emacs/elisp/my-cheeseboard.el) | 0 | ||||
-rw-r--r-- | lisp/my-uptime.el (renamed from emacs/elisp/my-uptime.el) | 0 |
8 files changed, 0 insertions, 230 deletions
diff --git a/emacs/elisp/my-buffers.el b/emacs/elisp/my-buffers.el deleted file mode 100644 index 8c03905..0000000 --- a/emacs/elisp/my-buffers.el +++ /dev/null @@ -1,39 +0,0 @@ -;;; my-buffers.el --- Functions related to buffer manipulations -;;; Commentary: -;;; Code: - -(defun my/copy-whole-buffer () - "Select the buffer and copy it." - (interactive) - (save-excursion - (mark-whole-buffer) - (copy-region-as-kill 1 (buffer-size)))) - -(defun my/rename-this-buffer-and-file () - "Renames current buffer and file it is visiting." - (interactive) - (let ((name (buffer-name)) - (filename (buffer-file-name)) - (read-file-name-function 'read-file-name-default)) - (if (not (and filename (file-exists-p filename))) - (error "Buffer '%s' is not visiting a file!" name) - (let ((new-name (read-file-name "New name: " filename))) - (cond ((get-buffer new-name) - (error "A buffer named '%s' already exists!" new-name)) - (t - (rename-file filename new-name 1) - (rename-buffer new-name) - (set-visited-file-name new-name) - (set-buffer-modified-p nil) - (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name)))))))) - -(defun my/uniquify-region-lines (beg end) - "Remove duplicate adjacent lines in region between BEG and END." - (interactive "*r") - (save-excursion - (goto-char beg) - (while (re-search-forward "^\\(.*\n\\)\\1+" end t) - (replace-match "\\1")))) - -(provide 'my-buffers) -;;; my-buffers.el ends here diff --git a/emacs/elisp/my-git-extra.el b/emacs/elisp/my-git-extra.el deleted file mode 100644 index 30fff78..0000000 --- a/emacs/elisp/my-git-extra.el +++ /dev/null @@ -1,50 +0,0 @@ -;;; my-git-extra.el --- Extra functions to work with git -;;; Commentary: -;;; Code: - -(require 'magit) -(require 'git-link) - -(defun my/clone-repo (url) - "Clone a repository in the workspace using URL." - (interactive "sURL:") - (let* ((repo-name (magit-clone--url-to-name url)) - (target-dir (concat "~/workspace/" repo-name))) - (magit-clone-regular url target-dir nil))) - -(defun my/sg-instance (hostname) - "Return the base URL for a sourcegraph instance based on HOSTNAME." - (cond ((string-match "cl\.fcuny\.net" hostname) (format "cs.fcuny.xyz/%s" hostname)) - (t (format "sourcegraph.rbx.com/%s" hostname)))) - -(defun my/git-link-sourcegraph (hostname dirname filename _branch commit start end) - "Create a link to sourcegraph given a HOSTNAME DIRNAME FILENAME _BRANCH COMMIT START and END." - (let ((sg-base-url (my/sg-instance hostname)) - ;; Use the default branch of the repository instead of the - ;; current one (we might be on a feature branch that is not - ;; available on the remote). - (main-branch (magit-main-branch)) - ;; repositories cloned with gerrit have a "a/" prefix which we - ;; need to remove, as it's not part of the repository name in - ;; sourcegraph. - (dirname (replace-regexp-in-string "a\/" "" dirname))) - (git-link-sourcegraph sg-base-url dirname filename main-branch commit start end))) - -(defun my/git-link-commit-sourcegraph (hostname dirname commit) - "Create the link to sourcegraph given a HOSTNAME DIRNAME and COMMIT." - (let ((sg-base-url (my/sg-instance hostname)) - (dirname (replace-regexp-in-string "a\/" "" dirname))) - (git-link-commit-sourcegraph sg-base-url dirname commit))) - -;; for work related repositories, open them in our instance of sourcegraph -(add-to-list 'git-link-remote-alist '("github\\.rbx\\.com" my/git-link-sourcegraph)) -(add-to-list 'git-link-commit-remote-alist '("github\\.rbx\\.com" my/git-link-work-sourcegraph)) - -;; for personal code I use cgit and gerrit -(add-to-list 'git-link-remote-alist '("git\\.fcuny\\.net" my/git-link-sourcegraph)) -(add-to-list 'git-link-remote-alist '("cl\\.fcuny\\.net" my/git-link-sourcegraph)) -(add-to-list 'git-link-commit-remote-alist '("git\\.fcuny\\.net" my/git-link-commit-sourcegraph)) -(add-to-list 'git-link-commit-remote-alist '("cl\\.fcuny\\.net" my/git-link-commit-sourcegraph)) - -(provide 'my-git-extra) -;;; my-git-extra.el ends here diff --git a/emacs/elisp/my-packages-extra.el b/emacs/elisp/my-packages-extra.el deleted file mode 100644 index de37752..0000000 --- a/emacs/elisp/my-packages-extra.el +++ /dev/null @@ -1,65 +0,0 @@ -;;; my-packages-extra.el --- Provides additional functions related to -;;; packages - -;;; Commentary: - -;;; Code: - -(require 'package) - -;; Original idea: https://www.manueluberti.eu/emacs/2021/09/01/package-report/ -(defun my/package-report () - "Report total package counts grouped by archive." - (interactive) - (package-refresh-contents) - (my/display-package-report - (let* ((arch-pkgs (my/archive-packages)) - (counts (seq-sort-by #'cdr #'> (my/archive-counts arch-pkgs))) - (by-arch (seq-group-by #'car arch-pkgs))) - (concat - (format "Total packages: %s\n\n" (apply #'+ (mapcar #'cdr counts))) - (mapconcat - (lambda (archive) - (concat "• " - (format "%s (%s)" (car archive) (cdr archive)) - ": " - (mapconcat (lambda (ap-pair) (cdr ap-pair)) - (alist-get (car archive) by-arch) - ", "))) - counts - "\n\n"))))) - -(defun my/display-package-report (output) - "Display OUTPUT in a popup buffer." - (let ((buffer-name "*package-report*")) - (with-help-window buffer-name - (with-current-buffer buffer-name - (visual-line-mode 1) - (erase-buffer) - (insert output) - (goto-char (point-min)))))) - -(defun my/archive-packages () - "Return a list of (archive . package) cons cells." - (seq-reduce - (lambda (res package) - (let ((archive (package-desc-archive - (cadr (assq package package-archive-contents)))) - (pkg (symbol-name package))) - (push (cons archive pkg) res))) - (mapcar #'car package-alist) - nil)) - -(defun my/archive-counts (arch-pkgs) - "Return a list of cons cells from alist ARCH-PKGS. -The cars are package archives, the cdrs are the number of -packages installed from each archive." - (seq-reduce - (lambda (counts key) - (cons (cons key (+ 1 (or (cdr (assoc key counts)) 0))) - (assoc-delete-all key counts))) - (mapcar #'car arch-pkgs) - nil)) - -(provide 'my-packages-extra) -;;; my-packages-extra.el ends here diff --git a/emacs/elisp/my-strings.el b/emacs/elisp/my-strings.el deleted file mode 100644 index 40ad888..0000000 --- a/emacs/elisp/my-strings.el +++ /dev/null @@ -1,23 +0,0 @@ -;;; my-strings.el --- Functions related to strings manipulation -;;; Commentary: -;;; Code: - -(defun my/remove-sql-columns () - "Remove \"|\" from strings. -This is useful when I want to drop the column separator from some -text coming from a mysql query." - (interactive) - (while (search-forward-regexp "\s?|\s?") - (replace-match " "))) - -;; from https://karl-voit.at/2014/08/10/bookmarks-with-orgmode/ -(defun my/string-replace (this withthat in) - "Replace THIS with WITHTHAT' in the string IN." - (with-temp-buffer - (insert in) - (goto-char (point-min)) - (replace-string this withthat) - (buffer-substring (point-min) (point-max)))) - -(provide 'my-strings) -;;; my-strings.el ends here diff --git a/emacs/elisp/my-web.el b/emacs/elisp/my-web.el deleted file mode 100644 index 4e86790..0000000 --- a/emacs/elisp/my-web.el +++ /dev/null @@ -1,32 +0,0 @@ -;;; my-web.el --- Functions related to web interactions -;;; Commentary: -;;; Code: - -(require 'my-strings) - -(defun my/get-page-title (url) - "Make URL into an 'org-mode' link." - (let ((title)) - (with-current-buffer (url-retrieve-synchronously url) - (goto-char (point-min)) - (re-search-forward "<title>\\([^<]*\\)</title>" nil t 1) - (setq title (match-string 1)) - (goto-char (point-min)) - (re-search-forward "charset=\\([-0-9a-zA-Z]*\\)" nil t 1) - (my/string-replace " " " " - (decode-coding-string title 'utf-8)) - (concat "[[" url "][" title "]]")))) - -(defun my/github-code-search () - "Search code on github for a given language." - (interactive) - (let ((language (completing-read - "Language: " - '("Emacs Lisp" "Python" "Go" "Nix"))) - (code (read-string "Code: "))) - (browse-url - (concat "https://github.com/search?l=" language - "&type=code&q=" code)))) - -(provide 'my-web) -;;; my-web.el ends here diff --git a/emacs/elisp/my-work.el b/emacs/elisp/my-work.el deleted file mode 100644 index f0c59d8..0000000 --- a/emacs/elisp/my-work.el +++ /dev/null @@ -1,21 +0,0 @@ -;;; my-work.el --- Functions related to work -;;; Commentary: -;;; Code: - -(defun my/check-work-machine-p () - "Return t if this is a work machine." - (string-match "HQ\\.*" (system-name))) - -(defun my/work-code-search () - "Search code on sourcegraph for a given language." - (interactive) - (let ((language (completing-read - "Language: " - '("Ruby" "Python" "Go"))) - (code (read-string "Code: "))) - (browse-url - (concat "https://sourcegraph.rbx.com/search?q=context:global+lang:" language - "+" code)))) - -(provide 'my-work) -;;; my-work.el ends here diff --git a/emacs/elisp/my-cheeseboard.el b/lisp/my-cheeseboard.el index 9713e14..9713e14 100644 --- a/emacs/elisp/my-cheeseboard.el +++ b/lisp/my-cheeseboard.el diff --git a/emacs/elisp/my-uptime.el b/lisp/my-uptime.el index 77c9957..77c9957 100644 --- a/emacs/elisp/my-uptime.el +++ b/lisp/my-uptime.el |