;; ;; MELPA ;; (require 'package) (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) (not (gnutls-available-p)))) (proto (if no-ssl "http" "https"))) (when no-ssl (warn "\ Your version of Emacs does not support SSL connections, which is unsafe because it allows man-in-the-middle attacks. There are two things you can do about this warning: 1. Install an Emacs version that does support SSL and be safe. 2. Remove this warning from your init file so you won't see it again.")) ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t) ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t) (when (< emacs-major-version 24) ;; For important compatibility libraries like cl-lib (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))))) (package-initialize) (require 'tramp) ;; ;; fixup Tramp controlmaster options ;;;;(setq tramp-ssh-controlmaster-options "") (customize-set-variable 'tramp-ssh-controlmaster-options (concat "-o ControlPath=/tmp/ssh-ControlPath-%%r@%%h:%%p " "-o ControlMaster=auto -o ControlPersist=yes")) ;; ;; Always have recentf buffers going ;; (recentf-mode) (require 'helm-org) (require 'helm-org-rifle) ;; ;; Set up helm-buffers to work ;; (global-set-key (kbd "C-x C-b") 'helm-mini) (global-set-key (kbd "C-x C-r") 'helm-org-rifle) ;; ;; Activation of org-mode ;; (global-set-key (kbd "C-c l") 'org-store-link) (global-set-key (kbd "C-c a") 'org-agenda) (global-set-key (kbd "C-c c") 'org-capture) ;; Set up org-journal (require 'org-journal) (global-set-key (kbd "C-c C-j") 'org-journal-new-entry) ;; ;; Automatically run org-indent-mode ;; (add-hook 'org-mode-hook 'org-indent-mode) ;; ;; enable pdf-tools to run ;; (pdf-tools-install) ;; ;; Magit-mode bindings ;; (global-set-key (kbd "C-x g") 'magit-status) ;; ;; Line transposition code ;; Using M-up, M-down, etc. ;; (global-set-key (kbd "M-") 'move-dup-move-lines-down) (global-set-key (kbd "M-") 'move-dup-move-lines-up) ;; ;; Get helm-perldoc up and running ;; (require 'helm-perldoc) (helm-perldoc:setup) ;; ;; Make M-y do helm-killring stuff ;; (global-set-key (kbd "M-y") 'helm-show-kill-ring) ;; ;; ;; ;; Make org-pdfview work ;; ;; ;; (require 'org-pdfview) ;; ;; Make cperl indent as I like ;; (setq cperl-indent-level 4) ;; ;; Set up google-translate ;; ;; (require 'google-translate) ;; (require 'google-translate-default-ui) ;; (global-set-key "\C-ct" 'google-translate-at-point) ;; (global-set-key "\C-cT" 'google-translate-query-translate) ;; ;; Function to revert all buffers (useful for syncthing) ;; (defun modi/revertall-filebuffers () "Refresh all open file buffers without confirmation. Buffers in modified (not yet saved) state in emacs will not be reverted. They will be reverted though if they were modified outside emacs. Buffers visiting files which do not exist any more or are no longer readable will be killed." (interactive) (dolist (buf (buffer-list)) (let ((filename (buffer-file-name buf))) ;; Revert only buffers containing files, which are not modified; ;; do not try to revert non-file buffers like *Messages*. (when (and filename (not (buffer-modified-p buf))) (if (file-readable-p filename) ;; If the file exists and is readable, revert the buffer. (with-current-buffer buf (revert-buffer :ignore-auto :noconfirm :preserve-modes)) ;; Otherwise, kill the buffer. (let (kill-buffer-query-functions) ; No query done when killing buffer (kill-buffer buf) (message "Killed non-existing/unreadable file buffer: %s" filename)))))) (message "Finished reverting buffers containing unmodified files.")) ;; ;; Set CPerl-mode to be the default ;; (defalias 'perl-mode 'cperl-mode) ;; ;; Improve linking to comments in perl code ;; (add-hook 'org-create-file-search-functions (lambda () "Crée des liens avec un numéro de ligne pour les fichiers de code source. (make links with a line number for source code files.)" (when (memq major-mode '(cperl-mode sh-mode makefile-gmake-mode)) ;; Je préfère éditer la description des liens manuellement, plutôt que ;; de la saisir au minibuffer. (concat "*" (string-trim (org-current-line-string)))))) ;; ;; ;; ;; Give me back the " 'left-word) ;; (bind-key* "C-" 'right-word) ;; ;; Replace-regexp, the right way of replacing! ;; (global-set-key (kbd "C-x M-%") 'replace-regexp) ;; ;; Five-ify ;; ;; (fset 'five-ify-variable-lines ;; (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([1 tab 67108896 19 44 19 19 19 19 return 24 134217765 17 10 32 42 return 32 return 1 tab 19 44 19 19 19 19 return return] 0 "%d")) arg))) (fset 'five-ify-line-advanced [?\C-a tab ?\C- ?\C-s ?, ?\C-s ?\C-s ?\C-s ?\C-s right tab ?\C-x ?\M-% ?, ?\[ ? ?\C-q ?\C-i ?\C-q ?\C-j ?\] ?* return ?, ? return backspace return]) (global-set-key (kbd "C-c C-c 5") 'five-ify-line-advanced) (menu-bar-mode -1) (tool-bar-mode -1) ;; ;; ;; ;; ox-mediawiki export backend ;; ;; ;; (require 'ox-mediawiki) ;; ;; ;; ;; Setup emms ;; ;; ;; (require 'emms-setup) ;; (require 'emms-player-mpv) ;; (emms-standard) ;; (emms-default-players) ;; ;; (emms-player-for '(*track* (type . file) ;; ;; (name . "myfile.pls"))) ;; ;; Add org-plus-contrib ;; https://orgmode.org/elpa.html (require 'package) (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) ;; ;; ;; ;; org-bookmark ;; ;; ;; (add-to-list 'load-path "~/.emacs.d/bmkp/") ;; (require 'bookmark+) ;; ;; ;; ;; Set a key for looking through bookmarks ;; ;; ;; (global-set-key (kbd "C-x C-l") 'bookmark-bmenu-list) ;; ;; Show org-mode effort in C-c C-x C-c column view agenda ;; ref. https://emacs.stackexchange.com/questions/53272/show-effort-and-clock-time-in-agenda-view ;; (setq org-columns-default-format "%60ITEM(Task) %TODO %6Effort(Estim){:} %6CLOCKSUM(Clock) %TAGS") ;; ;; Un-bork C-x C-o ;; (global-set-key (kbd "C-x C-o") 'other-window) ;; ;; Experimental trampism ;; ;; (defun tramp-check-for-regexp (proc regexp) ;; "Check, whether REGEXP is contained in process buffer of PROC. ;; Erase echoed commands if exists." ;; (with-current-buffer (process-buffer proc) ;; (if (> (point-max) 1000) ;; (progn ;; (goto-char (point-max)) ;; (ignore-errors (re-search-backward regexp (- (point-max) 1000) t))) ;; (progn ;; (goto-char (point-min)) ;; ;; Check whether we need to remove echo output. ;; (when (and (tramp-get-connection-property proc "check-remote-echo" nil) ;; (re-search-forward tramp-echoed-echo-mark-regexp nil t)) ;; (let ((begin (match-beginning 0))) ;; (when (re-search-forward tramp-echoed-echo-mark-regexp nil t) ;; ;; Discard echo from remote output. ;; (tramp-set-connection-property proc "check-remote-echo" nil) ;; (tramp-message proc 5 "echo-mark found") ;; (forward-line 1) ;; (delete-region begin (point)) ;; (goto-char (point-min))))) ;; (when (or (not (tramp-get-connection-property proc "check-remote-echo" nil)) ;; ;; Sometimes, the echo string is suppressed on the remote side. ;; (not (string-equal ;; (tramp-compat-funcall ;; 'substring-no-properties tramp-echo-mark-marker ;; 0 (min tramp-echo-mark-marker-length (1- (point-max)))) ;; (tramp-compat-funcall ;; 'buffer-substring-no-properties ;; (point-min) ;; (min (+ (point-min) tramp-echo-mark-marker-length) ;; (point-max)))))) ;; ;; No echo to be handled, now we can look for the regexp. ;; ;; Sometimes, lines are much to long, and we run into a "Stack ;; ;; overflow in regexp matcher". For example, //DIRED// lines of ;; ;; directory listings with some thousand files. Therefore, we ;; ;; look from the end. ;; (goto-char (point-max)) ;; (ignore-errors (re-search-backward regexp nil t))))))) ;; ;; Get jq mode set properly ;; (add-to-list 'auto-mode-alist '("\\.jq\\'" . jq-mode)) (setq vc-ignore-dir-regexp (format "\\(%s\\)\\|\\(%s\\)" vc-ignore-dir-regexp tramp-file-name-regexp)) ;; https://old.reddit.com/r/emacs/comments/4366f9/how_do_orgrefiletargets_work/czg008y/ ;; Rework the targets for capturing org-files (setq org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9))) (setq org-outline-path-complete-in-steps nil) ; Refile in a single go (setq org-refile-use-outline-path t) ; Show full paths for refiling ;; ;; https://gitlab.com/oer/emacs-reveal ;; (add-to-list 'load-path "~/.emacs.d/elpa/emacs-reveal") ;; (require 'emacs-reveal) ;; Add the NCU method (push '("ncu" (tramp-login-program "nc") (tramp-login-args (("%h") ("%p"))) (tramp-remote-shell "/bin/sh")) tramp-methods) ;; ;; https://stackoverflow.com/a/24668842 ;; (add-hook 'json-mode-hook (lambda () (make-local-variable 'js-indent-level) (setq js-indent-level 2)))