diff --git a/IDE.el b/IDE.el index 0be1708..4a63083 100644 --- a/IDE.el +++ b/IDE.el @@ -37,7 +37,7 @@ docker-compose-mode org markdown-mode -;; neotree + sphinx-doc all-the-icons use-package highlight-symbol @@ -52,6 +52,7 @@ centaur-tabs rainbow-delimiters ;;12.4.21 smartparens;;12.4.21 + json-mode;;19.5. )) ;; org mode @@ -128,13 +129,9 @@ (define-key global-map (kbd "s-") 'next-buffer) ;; switch to next buffer (define-key global-map (kbd "s-") 'previous-buffer) ;; switch to previous buffer -;;) -;;(require 'ido -;;(ido-mode t) -(require 'python-mode) -;;(add-hook 'python-mode-hook 'anaconda-mode) -;;(add-hook 'python-mode-hook 'anaconda-eldoc-mode) -;; add scons file to the known python file list +;;python instead of python-mode (31.5.) +;;https://emacs.stackexchange.com/q/71954/21383 +(require 'python) (add-to-list 'auto-mode-alist '("\\SConstruct\\'" . python-mode)) ;; Normal Copy paste @@ -182,9 +179,9 @@ (setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt -i") -(message "Link snippets") -(setq snip1 "defs") -(setq snip2 "dph") +;(message "Link snippets") +(setq snip1 "snippets/defs") +(setq snip2 "snippets/dph") (setq middle "elpa/elpy-*/snippets/python-mode/") (setq path-helper1 (mapconcat 'identity (list IDE-path middle) "")) @@ -215,12 +212,12 @@ (show-paren-mode 1) ;; A static file list is really cool, like a modern IDE -(package-initialize) -(require 'package) -(add-to-list 'load-path "/home/marioschwaiger/.emacs.d/neotree") -(require 'neotree) -(global-set-key (kbd "C-x M-f") 'neotree-toggle) - (setq neo-window-fixed-size nil) +;;(package-initialize) +;;(require 'package) +;;(add-to-list 'load-path "/home/marioschwaiger/.emacs.d/neotree") +;;(require 'neotree) +;;(global-set-key (kbd "C-x M-f") 'neotree-toggle) +;; (setq neo-window-fixed-size nil) ;; Automatically save and restore sessions (setq desktop-dirname "~/.emacs.d/desktop/" @@ -253,13 +250,13 @@ ) ;; All modern IDEs have the feature to obtain a list of the current documents -(require 'all-the-icons) -(require 'neotree) -(global-set-key [f8] 'neotree-toggle) -(setq neo-theme (if (display-graphic-p) 'icons 'arrow)) +;;(require 'all-the-icons) +;;(require 'neotree) +;;(global-set-key [f8] 'neotree-toggle) +;;(setq neo-theme (if (display-graphic-p) 'icons 'arrow)) ;; I'm a Nerd -(setq neo-theme 'nerd) -(setq neo-vc-integration '(face)) +;;(setq neo-theme 'nerd) +;;(setq neo-vc-integration '(face)) ;; Showing differences to the last Git commit (require 'diff-hl) @@ -318,7 +315,7 @@ buffer in current window." (defun marioschwaiger/yas-python () (interactive) ;; (yas-expand-snippet (yas-lookup-snippet "cmake_minimum_required" 'cmake-mode))) - (yas-expand-snippet (yas-lookup-snippet "do_python_header" 'python-mode))) + (yas-expand-snippet (yas-lookup-snippet "dph" 'python-mode))) (use-package autoinsert @@ -364,13 +361,13 @@ buffer in current window." (doom-themes-visual-bell-config) ;; Enable custom neotree theme (all-the-icons must be installed!) -(doom-themes-neotree-config) +;;(doom-themes-neotree-config) ;; or for treemacs users -(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme -(doom-themes-treemacs-config) +;;(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme +;;(doom-themes-treemacs-config) ;; Corrects (and improves) org-mode's native fontification. -(doom-themes-org-config) +;;(doom-themes-org-config) (require 'sublimity) @@ -406,3 +403,115 @@ buffer in current window." ;; Similar for this mode ;; Always start smartparens mode in js-mode. (add-hook 'elpy-mode-hook 'smartparens-mode) + +;; 30.6.21 - Added Treemacs +(use-package treemacs + :ensure t + :defer t + :init + (with-eval-after-load 'winum + (define-key winum-keymap (kbd " SPC") #'treemacs-select-window)) + :config + (progn + (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) + treemacs-deferred-git-apply-delay 0.5 + treemacs-directory-name-transformer #'identity + treemacs-display-in-side-window nil + treemacs-eldoc-display t + treemacs-file-event-delay 500000 + treemacs-file-extension-regex treemacs-last-period-regex-value + treemacs-file-follow-delay 0.2 + treemacs-file-name-transformer #'identity + treemacs-follow-after-init t + treemacs-expand-after-init t + treemacs-git-command-pipe "" + treemacs-goto-tag-strategy 'refetch-index + treemacs-indentation 2 + treemacs-indentation-string " " + treemacs-is-never-other-window nil + treemacs-max-git-entries 5000 + treemacs-missing-project-action 'ask + treemacs-move-forward-on-expand nil + treemacs-no-png-images nil + treemacs-no-delete-other-windows t + treemacs-project-follow-cleanup nil + treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) + treemacs-position 'left + treemacs-read-string-input 'from-child-frame + treemacs-recenter-distance 0.1 + treemacs-recenter-after-file-follow nil + treemacs-recenter-after-tag-follow nil + treemacs-recenter-after-project-jump 'always + treemacs-recenter-after-project-expand 'on-distance + treemacs-litter-directories '("/node_modules" "/.venv" "/.cask") + treemacs-show-cursor nil + treemacs-show-hidden-files t + treemacs-silent-filewatch nil + treemacs-silent-refresh nil + treemacs-sorting 'alphabetic-asc + treemacs-space-between-root-nodes t + treemacs-tag-follow-cleanup t + treemacs-tag-follow-delay 1.5 + treemacs-user-mode-line-format nil + treemacs-user-header-line-format nil + treemacs-width 35 + treemacs-width-is-initially-locked nil + treemacs-workspace-switch-cleanup nil) + + ;; The default width and height of the icons is 22 pixels. If you are + ;; using a Hi-DPI display, uncomment this to double the icon size. + ;;(treemacs-resize-icons 44) + + (treemacs-follow-mode t) + (treemacs-filewatch-mode t) + (treemacs-fringe-indicator-mode 'always) + (pcase (cons (not (null (executable-find "git"))) + (not (null treemacs-python-executable))) + (`(t . t) + (treemacs-git-mode 'deferred)) + (`(t . _) + (treemacs-git-mode 'simple)))) + :bind + (:map global-map + ("M-0" . treemacs-select-window) + ("C-x t 1" . treemacs-delete-other-windows) + ("C-x t t" . treemacs) + ("C-x t B" . treemacs-bookmark) + ("C-x t C-t" . treemacs-find-file) + ("C-x t M-t" . treemacs-find-tag))) + +;;(define-key treemacs-mode-map [mouse-1] #'treemacs-single-click-expand-action) +(with-eval-after-load 'treemacs + (define-key treemacs-mode-map [mouse-1] #'treemacs-single-click-expand-action)) +(use-package treemacs-projectile + :after (treemacs projectile) + :ensure t) + +(use-package treemacs-icons-dired + :after (treemacs dired) + :ensure t + :config (treemacs-icons-dired-mode)) + +(use-package treemacs-magit + :after (treemacs magit) + :ensure t) + +(use-package treemacs-persp ;;treemacs-perspective if you use perspective.el vs. persp-mode + :after (treemacs persp-mode) ;;or perspective vs. persp-mode + :ensure t + :config (treemacs-set-scope-type 'Perspectives)) + +(add-hook 'emacs-startup-hook 'treemacs) + +(use-package auto-package-update + :ensure t + :config + (setq auto-package-update-delete-old-versions t + auto-package-update-interval 4) + (auto-package-update-maybe)) + + +;;This is used for the Autodoc +(add-hook 'python-mode-hook (lambda () + (require 'sphinx-doc) + (sphinx-doc-mode t))) diff --git a/README.md b/README.md index 75bd83b..6a68faf 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ $ git clone https://github.com/maldun/emacs_python_ide .emacs.d/ #Adding: $ echo '(setq IDE-path "~/.emacs.d/")' >> .emacs $ echo "(load (mapconcat 'identity (list IDE-path \"IDE.el\") \"\"))" >> .emacs -$ emacs #Have fun, but this might take just a little +$ emacs #Have fun, but this might take just a little, but you have to exit again if you want the snippets to be set +$ cd .emacs.d && chmod +x set_snippets.sh &&./set_snippets.sh #Now all the folders exist ``` to your .emacs @@ -37,17 +38,39 @@ with pip. If not, use: ```pip3 install --user black flake8 jedi rope importmagic``` +### Personalized Header Files for Python. +In the IDE.el, look up the line: +```marioschwaiger/yas-python``` +Change the name and whatever is required. This will be the default header for any *.py* File + +## Seriously, what are these things +During the process of constant improvement I notice quite often I do not know myself which of the packages are doing what. If something doesn't behave properly here's what to blame: + + +#### rainbow-delimiters +Colours brackets accordingly and gives a strong visual feedback if brackets are missed + +#### centaur-tabs +Gives emacs tabs like in most modern applications + ### Sphinx-Compatible defs and Shor Do a backup of your .emacs.d/elpa/elpy-20190130.2109/snippets/python-mode/defs Then do symbolic links. pdbpm, dph and rpdb are useful shortcuts for debugging-features which are not defined by default: ``` -ln -s /home/$USER/.emacs.d/defs /home/$USER/.emacs.d/elpa/elpy-DATE.VERSION/snippets/python-mode/defs -ln -s /home/$USER/.emacs.d/pdbpm /home/$USER/.emacs.d/elpa/elpy-DATE.VERSION/snippets/python-mode/pdbpm -ln -s /home/$USER/.emacs.d/dph /home/$USER/.emacs.d/elpa/elpy-DATE.VERSIO/snippets/python-mode/ -ln -s /home/$USER/.emacs.d/rpdb /home/$USER/.emacs.d/elpa/elpy-DATE.VERSIO/snippets/python-mode/ +~/.emacs.d$ ./set_snippets.sh +``` +## Snippets +Bear in mind there are (at least) two folders for snippets: +``` +./elpa/elpy-20*.*/snippets/python-mode/ +``` +For all the short-cuts that are used in everyday-programming +``` +./elpa/yasnippet-snippets-20*.*/snippets/emacs-lisp-mode/ ``` +That is used for instance if a new file is create and the snippet dph is ran against it. The remote_pdb (rpdb) in its currenct configuration can be accessed with the following command: ```$ telnet localhost 4444``` diff --git a/ipdb b/ipdb deleted file mode 100755 index 31edbe6..0000000 --- a/ipdb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -ipython3 --simple-prompt -c "%run -d $@" diff --git a/set_snippets.sh b/set_snippets.sh new file mode 100755 index 0000000..f6372f2 --- /dev/null +++ b/set_snippets.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# elpa/elpy-20220627.1416/ + +#If /set_snippets.sh -c is called nothing happens, just checking + + +CHECKONLY=1 + +if [ "$#" -eq "0" ] ; then +# echo "No arguments supplied" + CHECKONLY=1 +else + if [ ! -z "$1" ] ; then + if [ "$1" == "-c" ] ; then +# echo "P1 is -c" + CHECKONLY=0 + echo "ReadOnly Mode" + else +# echo "P1 is not -c" +# echo "P1 is {$1}" + CHECKONLY=1 + fi + else +# echo "P1 is not set" + CHECKONLY=1 + fi +fi + +#echo ${CHECKONLY} +#echo "$1" + +if [ "$1" = "-l" ] ; then + echo "Delete Mode" +fi +if [ "$1" = "-p" ] ; then + echo "Persistent Mode" +fi + +FILPA=$(pwd) +cd elpa +ELPY=$(ls -d elpy*) +LONGPA=${ELPY}/snippets/python-mode/ +cd .. + +for file in snippets/*; do + ORIGFILE=$(pwd)/${file} + FULLFILE=${FILPA}/elpa/${LONGPA}$(basename ${file}) + OLDFILE=${FULLFILE}_old + if [ -L ${FULLFILE} ] ; then + if [ -e ${FULLFILE} ] ; then + echo "Good link: ${FULLFILE} " + #Check option -c + if [ "$CHECKONLY" = 1 ] ; then + if [ -f ${OLDFILE} ]; then + echo ${OLDFILE} + rm ${OLDFILE} + fi + if [ "$1" = "-l" ] ; then + echo "Remove set removing: ${FULLFILE} " + rm ${FULLFILE} + else + echo "Moving to old_file instead of deleting" + mv ${FULLFILE} ${OLDFILE} + fi + fi + + else + echo "Broken link: ${FULLFILE} " + if [ "$CHECKONLY" = 1 ] ; then + echo "rm ${FULLFILE}" + rm ${FULLFILE} + fi + fi + elif [ -e ${FULLFILE} ] ; then + echo "Not a link: ${FULLFILE}" + if [ "$CHECKONLY" = 1 ] ; then + if [ -f ${OLDFILE} ]; then + echo ${OLDFILE} + rm ${OLDFILE} + fi + echo "Moving as it's not a link" + mv ${FULLFILE} ${OLDFILE} + fi + else + echo "Missing: ${FULLFILE}" + fi + + if [ "$CHECKONLY" = 1 ] ; then + if [ "$1" = "-p" ] ; then + echo "Moving: ${ORIGFILE} ${FULLFILE}" + cp ${ORIGFILE} ${FULLFILE} + else + echo "Setting Link ${ORIGFILE} ${FULLFILE}" + ln -s ${ORIGFILE} ${FULLFILE} + fi + fi +done + + + diff --git a/defs b/snippets/defs similarity index 100% rename from defs rename to snippets/defs diff --git a/dph b/snippets/dph similarity index 86% rename from dph rename to snippets/dph index 0ad5280..424ad5a 100644 --- a/dph +++ b/snippets/dph @@ -10,7 +10,7 @@ ############################################# __author__ = "Mario Schwaiger" __copyright__ = "Copyright `(format-time-string "%Y")`$0, Virtual Vehicle" -__credits__ = ["Stefan Reiterer", "Mario Schwaiger", "Michael Kalab", "Angelika More"] +__credits__ = ["Stefan Reiterer", "Mario Schwaiger"] __version__ = "0.1" __maintainer__ = "Mario Schwaiger" __email__ = "mario.schwaiger@v2c2.at" diff --git a/snippets/ipdb b/snippets/ipdb new file mode 100644 index 0000000..ad69a2b --- /dev/null +++ b/snippets/ipdb @@ -0,0 +1,11 @@ +# -*- mode: snippet; require-final-newline: nil -*- +# name: ipdb trace +# key: ipdb +# group: debug +# -- +# fmt: off +#`(format-time-string "%d.%m.%Y %H:%M")`$0 +import ipdb +ipdb.set_trace() # NOQA +# fmt: on + diff --git a/pdbpm b/snippets/pdbpm similarity index 100% rename from pdbpm rename to snippets/pdbpm diff --git a/rpdb b/snippets/rpdb similarity index 74% rename from rpdb rename to snippets/rpdb index 47f28ad..718837f 100644 --- a/rpdb +++ b/snippets/rpdb @@ -1,5 +1,5 @@ # -*- mode: snippet -*- -# name: remote_pdb (0.0.0.0:4444) +# name: remote_pdb telnet localhost 4444 # key: rpdb # group: debug # --