[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/crux a6e0a52 043/112: Define a minor mode for crux-reopen-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/crux a6e0a52 043/112: Define a minor mode for crux-reopen-as-root (#28) |
Date: |
Wed, 11 Aug 2021 09:57:50 -0400 (EDT) |
branch: elpa/crux
commit a6e0a523aabaab8df9b597ea39b3fc7baa563a2f
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Define a minor mode for crux-reopen-as-root (#28)
Rather than changing the default find-file behavior, providing a minor
mode enables users to opt-in or toggle the behavior.
Fixes #20.
---
README.md | 8 ++++++++
crux.el | 9 ++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 71fc7c1..db4dcee 100644
--- a/README.md
+++ b/README.md
@@ -114,6 +114,14 @@ current line, rather than the whole line, in the absence
of a region:
(crux-with-region-or-point-to-eol kill-ring-save)
```
+## Minor modes
+
+#### `(crux-reopen-as-root-mode)` ####
+
+Crux provides a `crux-reopen-as-root` command for reopening a file as
+root. This global minor mode changes `find-file` so all root files are
+automatically opened as root.
+
## License
Copyright © 2015 Bozhidar Batsov and [contributors][].
diff --git a/crux.el b/crux.el
index ff88d40..1c3d857 100644
--- a/crux.el
+++ b/crux.el
@@ -327,7 +327,14 @@ buffer is not visiting a file."
(crux-file-owned-by-user-p buffer-file-name))
(crux-find-alternate-file-as-root buffer-file-name)))
-(add-hook 'find-file-hook #'crux-reopen-as-root)
+;;;###autoload
+(define-minor-mode crux-reopen-as-root-mode
+ "Automatically reopen files as root if we can't write to them
+as the current user."
+ :global t
+ (if crux-reopen-as-root-mode
+ (add-hook 'find-file-hook #'crux-reopen-as-root)
+ (remove-hook 'find-file-hook #'crux-reopen-as-root)))
(defun crux-insert-date ()
"Insert a timestamp according to locale's date and time format."
- [nongnu] elpa/crux 1967a75 041/112: Allow users to create directories with crux-rename-file-and-buffer, (continued)
- [nongnu] elpa/crux 1967a75 041/112: Allow users to create directories with crux-rename-file-and-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 582a68d 046/112: Fix the version header, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux bcbfdec 048/112: Don't assume ido when offering files from recentf (#33), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3b377b4 054/112: Add smart kill line function, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1c2c179 061/112: Improve a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2b6ddf0 060/112: Add missing space, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5a7201a 062/112: Fix a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 32baf6a 064/112: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux a71669e 033/112: Merge pull request #17 from jiegec/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux cf547b7 037/112: Typo Fix: Missed an s in transpose, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux a6e0a52 043/112: Define a minor mode for crux-reopen-as-root (#28),
ELPA Syncer <=
- [nongnu] elpa/crux 2cdf266 069/112: Insert literal s-exp instead of printing in crux-eval-and-replace (#50), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2b4bf62 074/112: Give crux group to crux-reopen-as-root-mode, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 772123a 081/112: Support using any shell creating function with crux-visit-term-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux b401f45 050/112: [Fix #35] Replace a deprecated function, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux ad42bcf 053/112: Support make `crux-cleanup-buffer-or-region` support makefiles, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e3c9714 055/112: Make crux-move-beginning-of-line function mode aware (#45), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1e591c5 031/112: Merge pull request #16 from jiegec/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux ca62859 038/112: Merge pull request #22 from dgtized/fix-tranpose-typo, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux fde9d4b 044/112: Fix malformed header line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5b3c815 047/112: Release 0.3, ELPA Syncer, 2021/08/11