Add C# configuration
This only contains 2 commands for the moment that help me work with Visual Studio solution files. One collects all the names of the projects in the Solution, the other one displays them in the buffer.
This commit is contained in:
parent
b5dd41c664
commit
51f5e1934d
1 changed files with 77 additions and 0 deletions
77
oni-csharp.el
Normal file
77
oni-csharp.el
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
;;; oni-csharp.el --- C# Configuration -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2019 Tom Willemse
|
||||||
|
|
||||||
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
|
;; Keywords: local
|
||||||
|
|
||||||
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
|
||||||
|
;; This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;; My C# configuration.
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(defvar oni-chsarp--projects (make-hash-table :test 'equal))
|
||||||
|
|
||||||
|
(defun oni-chsarp-collect-project-names ()
|
||||||
|
"Go through the current buffer and collect all the project names."
|
||||||
|
(interactive)
|
||||||
|
(clrhash oni-chsarp--projects)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (re-search-forward
|
||||||
|
(rx bol
|
||||||
|
"Project(\"{"
|
||||||
|
(group (minimal-match (1+ (or alphanumeric "-"))))
|
||||||
|
"}\") = \""
|
||||||
|
(group (minimal-match (1+ any)))
|
||||||
|
"\", \""
|
||||||
|
(minimal-match (1+ any))
|
||||||
|
"\", \"{"
|
||||||
|
(group (minimal-match (1+ any)))
|
||||||
|
"}\""
|
||||||
|
eol)
|
||||||
|
nil
|
||||||
|
:noerror)
|
||||||
|
(puthash (match-string-no-properties 3)
|
||||||
|
(match-string-no-properties 2)
|
||||||
|
oni-chsarp--projects))))
|
||||||
|
|
||||||
|
(defun oni-csharp-display-project-names ()
|
||||||
|
"Display the project names in the current buffer."
|
||||||
|
(interactive)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(remove-overlays (point-min) (point-max) 'oni-csharp--overlayp t)
|
||||||
|
(while (re-search-forward
|
||||||
|
(rx bol
|
||||||
|
(zero-or-more whitespace)
|
||||||
|
"{"
|
||||||
|
(group (minimal-match (one-or-more (or alphanumeric "-"))))
|
||||||
|
"} = {"
|
||||||
|
(group (minimal-match (one-or-more (or alphanumeric "-"))))
|
||||||
|
"}"
|
||||||
|
eol)
|
||||||
|
nil
|
||||||
|
:noerror)
|
||||||
|
(let ((current-overlay (make-overlay (line-beginning-position) (line-end-position))))
|
||||||
|
(overlay-put current-overlay 'after-string
|
||||||
|
(propertize (format " => %s" (gethash (match-string 1) oni-chsarp--projects))
|
||||||
|
'face '(:foreground "#808080")))
|
||||||
|
(overlay-put current-overlay 'oni-csharp--overlayp t)))))
|
||||||
|
|
||||||
|
(provide 'oni-csharp)
|
||||||
|
;;; oni-csharp.el ends here
|
Loading…
Reference in a new issue