<commit_before>;; Time-stamp: <2016-07-22 14:06:32 kmodi>

;; Miscellaneous config not categorized in other setup-* files

(fset 'yes-or-no-p 'y-or-n-p) ; Use y or n instead of yes or no

;; Delete stuff to a trash directory
(setq delete-by-moving-to-trash t)
(setq trash-directory
      (let ((dir (concat temporary-file-directory
                         (getenv "USER") "/.trash_emacs/"))) ; must end with /
        (make-directory dir :parents)
        dir))

;; Do not make mouse wheel accelerate its action (example: scrolling)
(setq mouse-wheel-progressive-speed nil)

;; Make apropos commands search more extensively
(setq apropos-do-all t)

;; On saving, automatically make a file an executable if it begins with "#!"
;; Example: #!/bin/csh
(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)

;; Uncompress->edit->save->compress .gz, .bz2, .Z files on the fly
(auto-compression-mode 1)

;; Send mail using `Sendmail' package
(setq send-mail-function #'sendmail-send-it)

;; url
;; First delete the old `url/' directory if present
(let ((url-dir-old (concat user-emacs-directory "url/")))
  (when (file-exists-p url-dir-old)
    (delete-directory url-dir-old :recursive)))
;; Solve the issue with `sx.el' when using that package simultaneously in
;; different emacs versions
(setq url-configuration-directory (let ((dir (concat user-emacs-directory
                                                     "url_" emacs-version-short "/")))
                                    (make-directory dir :parents)
                                    dir))

;; Execute the script in current buffer
;; http://ergoemacs.org/emacs/elisp_run_current_file.html
(defun modi/run-current-file (&optional eval-init)
  "Execute the current file.

If EVAL-INIT is non-nil, load the `init.el'.

For example, if the current buffer is the file xx.py, then it'll call
“python xx.py” in a shell. The file can be php, perl, python, ruby,
javascript, bash, ocaml, vb, elisp.  File extension is used to determine
what program to run.

If the file is modified, user is asked to save it first.

If the buffer major-mode is `emacs-lisp-mode', run `eval-buffer'.
If the buffer major-mode is `clojure-mode', run `cider-load-buffer'."
  (interactive "P")
  (if eval-init
      (load (locate-user-emacs-file "init.el"))
    (progn
      (when (buffer-modified-p)
        (when (y-or-n-p "Buffer modified. Do you want to save first?")
          (save-buffer)))

      (cond
       ((derived-mode-p 'emacs-lisp-mode)
        (eval-buffer) ; also works for .el.gz and .el.gpg files
        (message "Evaluated `%0s'." (buffer-name)))
       ((and (featurep 'cider)
             (derived-mode-p 'clojure-mode))
        (cider-load-buffer))
       (t
        (let* ((suffix-map '(("py" . "python")
                             ("rb" . "ruby")
                             ("sh" . "bash")
                             ("csh" . "tcsh")
                             ("pl" . "perl")
                             ("tex" . "pdflatex")
                             ("latex" . "pdflatex")
                             ("d" . "dmd -de -w -unittest -run")))
               (file-name (progn
                            ;; Save buffer as a file if it's not already a file.
                            (when (null (buffer-file-name)) (save-buffer))
                            (buffer-file-name)))
               (file-ext (file-name-extension file-name))
               (prog-name (cdr (assoc file-ext suffix-map)))
               (cmd-str (concat prog-name " \"" file-name "\"")))
          (if prog-name
              (progn
                ;; (view-echo-area-messages)
                (message "Running ...")
                (shell-command cmd-str "*run-current-file output*" ))
            (message "No recognized program file suffix for this file."))))))))
(bind-to-modi-map "l" #'modi/run-current-file)

;; Set the major mode for plain text/log files
(use-package text-mode
  :mode (("\\.log\\'" . text-mode)
         ("\\.f\\'" . text-mode)) ; I never need to code in Fortran
  :config
  (progn
    ;; http://emacs.stackexchange.com/a/16854/115
    (defun modi/text-mode-comments ()
      "Make text beginning with # look like comments."
      (font-lock-add-keywords nil '(("#.+" . font-lock-comment-face))))
    (add-hook 'text-mode-hook #'modi/text-mode-comments)))

;; Help Functions +
;; http://www.emacswiki.org/emacs/HelpPlus
(use-package help-fns+
  :config
  (progn
    (bind-keys
     :map help-map
      ("c"   . describe-key-briefly)
      ("C-c" . describe-command))
    (>=e "25.0"
        (bind-keys
         :map help-map
          ("o" . describe-symbol)))))

(>=e "25.0"
    (use-package saveplace
      :config
      (save-place-mode 1)))

(use-package browse-url
  :defer t
  :config
  (progn<commit_msg>No need to explicitly require saveplace<commit_after>;; Time-stamp: <2016-08-09 11:25:15 kmodi>

;; Miscellaneous config not categorized in other setup-* files

(fset 'yes-or-no-p 'y-or-n-p) ; Use y or n instead of yes or no

;; Delete stuff to a trash directory
(setq delete-by-moving-to-trash t)
(setq trash-directory
      (let ((dir (concat temporary-file-directory
                         (getenv "USER") "/.trash_emacs/"))) ; must end with /
        (make-directory dir :parents)
        dir))

;; Do not make mouse wheel accelerate its action (example: scrolling)
(setq mouse-wheel-progressive-speed nil)

;; Make apropos commands search more extensively
(setq apropos-do-all t)

;; On saving, automatically make a file an executable if it begins with "#!"
;; Example: #!/bin/csh
(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)

;; Uncompress->edit->save->compress .gz, .bz2, .Z files on the fly
(auto-compression-mode 1)

;; Send mail using `Sendmail' package
(setq send-mail-function #'sendmail-send-it)

;; url
;; First delete the old `url/' directory if present
(let ((url-dir-old (concat user-emacs-directory "url/")))
  (when (file-exists-p url-dir-old)
    (delete-directory url-dir-old :recursive)))
;; Solve the issue with `sx.el' when using that package simultaneously in
;; different emacs versions
(setq url-configuration-directory (let ((dir (concat user-emacs-directory
                                                     "url_" emacs-version-short "/")))
                                    (make-directory dir :parents)
                                    dir))

;; Execute the script in current buffer
;; http://ergoemacs.org/emacs/elisp_run_current_file.html
(defun modi/run-current-file (&optional eval-init)
  "Execute the current file.

If EVAL-INIT is non-nil, load the `init.el'.

For example, if the current buffer is the file xx.py, then it'll call
“python xx.py” in a shell. The file can be php, perl, python, ruby,
javascript, bash, ocaml, vb, elisp.  File extension is used to determine
what program to run.

If the file is modified, user is asked to save it first.

If the buffer major-mode is `emacs-lisp-mode', run `eval-buffer'.
If the buffer major-mode is `clojure-mode', run `cider-load-buffer'."
  (interactive "P")
  (if eval-init
      (load (locate-user-emacs-file "init.el"))
    (progn
      (when (buffer-modified-p)
        (when (y-or-n-p "Buffer modified. Do you want to save first?")
          (save-buffer)))

      (cond
       ((derived-mode-p 'emacs-lisp-mode)
        (eval-buffer) ; also works for .el.gz and .el.gpg files
        (message "Evaluated `%0s'." (buffer-name)))
       ((and (featurep 'cider)
             (derived-mode-p 'clojure-mode))
        (cider-load-buffer))
       (t
        (let* ((suffix-map '(("py" . "python")
                             ("rb" . "ruby")
                             ("sh" . "bash")
                             ("csh" . "tcsh")
                             ("pl" . "perl")
                             ("tex" . "pdflatex")
                             ("latex" . "pdflatex")
                             ("d" . "dmd -de -w -unittest -run")))
               (file-name (progn
                            ;; Save buffer as a file if it's not already a file.
                            (when (null (buffer-file-name)) (save-buffer))
                            (buffer-file-name)))
               (file-ext (file-name-extension file-name))
               (prog-name (cdr (assoc file-ext suffix-map)))
               (cmd-str (concat prog-name " \"" file-name "\"")))
          (if prog-name
              (progn
                ;; (view-echo-area-messages)
                (message "Running ...")
                (shell-command cmd-str "*run-current-file output*" ))
            (message "No recognized program file suffix for this file."))))))))
(bind-to-modi-map "l" #'modi/run-current-file)

;; Set the major mode for plain text/log files
(use-package text-mode
  :mode (("\\.log\\'" . text-mode)
         ("\\.f\\'" . text-mode)) ; I never need to code in Fortran
  :config
  (progn
    ;; http://emacs.stackexchange.com/a/16854/115
    (defun modi/text-mode-comments ()
      "Make text beginning with # look like comments."
      (font-lock-add-keywords nil '(("#.+" . font-lock-comment-face))))
    (add-hook 'text-mode-hook #'modi/text-mode-comments)))

;; Help Functions +
;; http://www.emacswiki.org/emacs/HelpPlus
(use-package help-fns+
  :config
  (progn
    (bind-keys
     :map help-map
      ("c"   . describe-key-briefly)
      ("C-c" . describe-command))
    (>=e "25.0"
        (bind-keys
         :map help-map
          ("o" . describe-symbol)))))

(>=e "25.0"
    (use-package saveplace
      :defer t
      :init
      (save-place-mode 1)))

(use-package browse-url
  :defer t
  :config
  (progn
{'fraction_non_alphanumeric': 0.14575359470363092, 'fraction_numerical': 0.0066204613634012624, 'mean_word_length': 2.017478152309613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '741374', 'n_tokens_mistral': 3158, 'n_tokens_neox': 3031, 'n_words': 876}