Want To Rewrite Your Configs In Org-Mode? It's Easy!

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024
  • One of the killer features of Emacs is Org-Mode, which is a kind of markdown that makes creating outlines, tables, source code blocks, and tables of content really easy. Often, when people discover Org-Mode, they start wanting to rewrite all of their configs as literate configs in Org.
    ERRATA:
    I mentioned in the video that this would work on any config file written in an actual programming language. That 's not actually the case. Tangle will work on anything, so it doesn't have to be a programming language, since we are not really evaluating the code with this. We are just writing what's in the SRC blocks to the file we specify.
    NOTE:
    I did all of this on a live stream earlier today but the stream had some buffering issues. I thought this topic was too important not to go back and re-record. I have removed the earlier live stream.
    REFERENCED:
    ► gitlab.com/dwt... - DT's README.org
    ► www.gnu.org/so... - GNU Emacs
    ► github.com/hli... - Doom Emacs
    ► orgmode.org/ - Org Mode Documentation
    WANT TO SUPPORT THE CHANNEL?
    💰 Patreon: / distrotube
    💳 Paypal: www.paypal.com...
    🛍️ Amazon: amzn.to/2RotFFi
    👕 Teespring: teespring.com/...
    SOCIAL PLATFORMS:
    🗨️ Mastodon: mastodon.techn...
    💬 IRC: irc://freenode #distrotube
    👫 Reddit: / distrotube
    📽️ LBRY: lbry.tv/$/invi...
    DT ON THE WEB:
    🕸️ Website: distrotube.com/
    🐿️ Gopherhole: gopher://distro.tube
    📁 GitLab: gitlab.com/dwt1
    FREE AND OPEN SOURCE SOFTWARE THAT I USE:
    🌐 Brave Browser - brave.com/dis872
    📽️ Open Broadcaster Software: obsproject.com/
    🎬 Kdenlive: kdenlive.org
    🎨 GIMP: www.gimp.org/
    🔊 Audacity: www.audacityte...
    💻 VirtualBox: www.virtualbox...
    Your support is very much appreciated. Thanks, guys!

ความคิดเห็น • 67

  • @robertdavis9948
    @robertdavis9948 4 ปีที่แล้ว +27

    Org mode is smart enough to wrap code block delimiters around selected text. Mark the block you want, then press "C-c ," and that will give you a nice menu. hit "s" to wrap the selected text in a source code block. I believe that "

  • @nicolasmorazotti8684
    @nicolasmorazotti8684 4 ปีที่แล้ว +33

    I've used emacs for about 8 years, org-mode for 4 years and didn't know about the :toc:

  • @robertdavis9948
    @robertdavis9948 4 ปีที่แล้ว +28

    In vanilla emacs, :toc: doesn't work like it does in Doom. You'll need to install the toc-org package to get the same functionality.

    • @DistroTube
      @DistroTube  4 ปีที่แล้ว +6

      Good to know! Thanks!

  • @AndersJackson
    @AndersJackson 4 ปีที่แล้ว +8

    Thanks, you have shown peopel the light in Emacs.
    This is a great way of document your config files, and that without lots and lots of comments in the code.
    You could also generate HTML, PFD, LaTeX, LibreOffice and plain text files from the Org-mpde too, so it get even easier to read for someone that want to have a look at your code.
    Would also recommend that the links get properly converted into named linkes, just put [] around the link. There are also a shortcut to make a text with a link into a proper link.
    But, thanks for showing the magic of Emacs. And as usual, I learn some stuff from looking at your videos about Emacs. And I started to use it back about 1985.

  • @TheFakeVIP
    @TheFakeVIP 4 ปีที่แล้ว +10

    Long time markdown user, but this is totally a reason to learn org-mode. You could definitely do this with a Pandoc filter for Markdown as well, and I might just try that, but whatever markup language, it's so cool you can do this, and it'll be so helpful to clean up my configs.

  • @bibleculture
    @bibleculture 3 ปีที่แล้ว +2

    I needed this! Thanks. I'm starting to rewrite my spacemacs config files this way. Read a few reddit posts and blogs, but videos are much better for this type of content.

  • @kubo407
    @kubo407 4 ปีที่แล้ว +6

    This is incredibly useful! I'm definitely going to start making more use of org-mode.

    • @AndersJackson
      @AndersJackson 4 ปีที่แล้ว

      It is great. Both for config files and also for programming. Tangeling was something Donald Knuth used that he called WEB programming, way back in time. But he didn't used Emacs for that. Org-mode wasn't invented yet. :-)
      I use it to generate my Emacs config and init.el. So yoou can tangel many different files and in many languages if you want to.
      There are even some people that write their PHd thesis in Emacs and tangle it into LaTeX, generating all data files etc. But of course you don't need to to do that if you don't want to.
      But in plain Emacs, C-c C-e l p generates PDF document from Org-mode file, and C-c C-e h h generates HTML document from the Org-mode file.

  • @markmake2252
    @markmake2252 2 ปีที่แล้ว

    Your videos inspired me a lot. I finally ditched macOS and Windows and I am using Arch Linux as my daily driver. This and all the other videos showing the wonders of Emacs and Org mode are also an added value to this switch. I found Emacs really intimidating at first, even by reading its tutorial and manual, let alone the Org-Mode-Bible-like manual... but your videos helped me to learn more and use this piece of software. I still have a lot to learn but I am already starting to use Emacs in my workflow. I wish you could also guide us into using Emacs as a mail client, or music player or anything else that it can do ! You are doing a great job indeed. There should be more people like you in this planet!

  • @HenriqueNewsted
    @HenriqueNewsted 4 ปีที่แล้ว +2

    This made me want to try emacs, and i've been a Vim user since i started on Linux (circa 2017). Thanks DT, if it weren't for you i would never know this.
    You are surely the best Linux youtuber out there!

    • @Archwyrm
      @Archwyrm 4 ปีที่แล้ว

      The neat thing about Doom Emacs or vanilla Emacs with evil-mode is you can be a Vim user *and* an Emacs user. :)
      I've been using Vim since 2003 and am recently exploring all that Emacs has to offer like org-mode and customizing in Elisp!

  • @tomaso0
    @tomaso0 4 ปีที่แล้ว +24

    0:07 The org language is a form of markup language, but not related to markdown in any way apart from that

    • @semilin
      @semilin 4 ปีที่แล้ว +6

      I think he meant to say markup

    • @driden1987
      @driden1987 4 ปีที่แล้ว +1

      Was about to make this comment myself, thanks @tomaslib

  • @auroradraco9974
    @auroradraco9974 4 ปีที่แล้ว +4

    This is honestly great, org mode really is a killer feature.

  • @kristiannordin7765
    @kristiannordin7765 2 ปีที่แล้ว +1

    Thank you for this video. Been searching the web to make this work but didnt find a solution that made sense to me.
    After watching your video everything is working perfectly.
    Thank you!

  • @aleksandrpetrosyan1140
    @aleksandrpetrosyan1140 4 ปีที่แล้ว +10

    You can tangle anything you like. So you can do i3, and SpectrWM confirms in Org.

    • @DistroTube
      @DistroTube  4 ปีที่แล้ว +1

      Nice!

    • @aleksandrpetrosyan1140
      @aleksandrpetrosyan1140 4 ปีที่แล้ว +5

      @@DistroTube specifically, you set the file name to the file name, o
      I.e.
      =:tangle .config/i3/config=
      As seen in orgmode.org/manual/Extracting-Source-Code.html

    • @aleksandrpetrosyan1140
      @aleksandrpetrosyan1140 4 ปีที่แล้ว +2

      @@DistroTube I would also recommend github.com/mtekman/org-tanglesync.el

    • @DeshierArchitecte
      @DeshierArchitecte 3 ปีที่แล้ว

      What do you specify as the language in the code block then? Just plain text?

    • @aleksandrpetrosyan1140
      @aleksandrpetrosyan1140 3 ปีที่แล้ว

      @@DeshierArchitecte See my other replies.

  • @kaiocesar8578
    @kaiocesar8578 4 ปีที่แล้ว +11

    I don't see why it will only work with programming languages scripts

    • @DistroTube
      @DistroTube  4 ปีที่แล้ว +12

      Actually, I was corrected on this by another commenter. Tangle will work on anything so it doesn't have to be a programming language, since we are not really evaluating the code with this. We are just writing what's in the SRC blocks to the file we specify.

  • @JeffChien13
    @JeffChien13 2 ปีที่แล้ว

    you have successfully made me switch from vim to emacs. also I found that tangle can work for any text content not just programming languages, all it needs is to call revert-buffer.

  • @FrederickCai
    @FrederickCai 4 ปีที่แล้ว +2

    One thing kinda annoying me is, if you move to 5:28, you will see even you've wrapped the code in source code block, it won't highlight them until you move to `#+BEGIN_SRC`.

  • @alan_core
    @alan_core 4 ปีที่แล้ว +2

    Thanks for the hard work Derek, stay safe

  • @dantebarbieri
    @dantebarbieri 4 ปีที่แล้ว +7

    I love this idea and want to rewrite my dotfiles in org mode, but for some files like bspwmrc which is a shell file that requires executable permissions, tangle removes the permissions. Is there a way to make the tangle output with the executable permission set?

    • @dantebarbieri
      @dantebarbieri 4 ปีที่แล้ว +9

      Surprise surprise, the answer was in the documentation. orgmode.org/org.html#Working-with-Source-Code
      In short:
      There is a shebang property that sets the file executable and adds a shebang, there is a way to set it executable without the shebang property using `:tangle-mode (identity #o755)`.
      The Shebang property: `:shebang "#!/bin/bash"`
      To set multiple properties you need to either do it on one line: `#+PROPERTY: header-args :tangle bspwm :shebang "#!/bin/bash"`
      Or you must specify that you are appending to the property:
      ```
      #+PROPERTY: header-args :tangle bspwm
      #+PROPERTY: header-args+ :shebang "#!/bin/bash"
      ```
      Make sure that you reload whenever you change the property or tangle will not output correctly. I kept getting 0 blocks output until I reloaded with C-c C-c. Hope this helps somebody!

    • @DistroTube
      @DistroTube  4 ปีที่แล้ว +5

      Glad you got it working. And thanks for posting the solution here. Others will definitely need it! :D

  • @digitalife8719
    @digitalife8719 10 หลายเดือนก่อน

    Short version of the tutorial.
    1.Make your file like this:
    #+PROPERTY: header-args :tangle output_file.py
    * entry_1
    #+BEGIN_SRC python
    print('hello')
    #+END_SRC
    * entry_2
    #+BEGIN_SRC python
    print('world')
    #+END_SRC
    2. Put the cursor in the #+PROERTY line. Refresh local setups with C-c C-c,
    3. Then, M-x org-babel-tange ENTER, to execute command org-babel-tangle to output code in all code blocks into file output_file.py, in the same directory of current org file.

  • @Phydoux2112
    @Phydoux2112 4 ปีที่แล้ว +3

    Wow! This is some cool stuff! Time for me to get serious about Emacs!

  • @mohammedalbatati5529
    @mohammedalbatati5529 2 ปีที่แล้ว

    Thanks alot DT
    I started changing all my README files to org mode
    It looks much better

  • @patrykgronkiewicz924
    @patrykgronkiewicz924 4 ปีที่แล้ว +9

    4:50 you could do ggyG instead of ggVGy

  • @TDOLLA
    @TDOLLA 6 หลายเดือนก่อน

    damnit… I JUST got to a point where I got a solid understanding of neovim and can customize it to my liking and understand the config and modular file structure. Now I want to go start on emacs

  • @hayopapayo1717
    @hayopapayo1717 4 ปีที่แล้ว +2

    nice, could not watch live stream, was searching for the recordings and couldnt find it ^^

  • @uuu12343
    @uuu12343 2 ปีที่แล้ว

    Question
    I assume this will require emacs to be installed as a dependency for all installs?
    Because doesn't this mean that the config files are in emacs-lisp language as opposed to the correct dotfile Syntax?

  • @cornelisdejong1523
    @cornelisdejong1523 3 ปีที่แล้ว +1

    You might consider using the expand-region package {melpa} which facilitates selection. Besides legacy emacs includes mark-whole-buffer, which I've bound to C-a {naturally!}.

  • @otavioschwanck6668
    @otavioschwanck6668 4 ปีที่แล้ว

    Tip:
    You can go to dired mode with SPC . and selecting a folder instead a file. You can use SPC . to create files too.

  • @jeremyottley4141
    @jeremyottley4141 4 ปีที่แล้ว +1

    Hey DT? What aspects made you choose Doom Emacs over Prelude or Spacemacs?

  • @rohscx
    @rohscx 2 ปีที่แล้ว

    Good stuff DT

  • @AnzanHoshinRoshi
    @AnzanHoshinRoshi 4 ปีที่แล้ว +1

    Thank you, Derek.

  • @techforfreedom6023
    @techforfreedom6023 4 ปีที่แล้ว +2

    Hey DT put video about Elisp tutorials. Emacs users want that. good luck.

  • @bobkoss280
    @bobkoss280 2 ปีที่แล้ว

    Excellent!

  • @brunogama9346
    @brunogama9346 4 ปีที่แล้ว

    Where did you buy that awesome mug?

  • @yiannifunataoldotcom
    @yiannifunataoldotcom 3 ปีที่แล้ว

    Thank you! I really liked that

  • @jr_Linux
    @jr_Linux ปีที่แล้ว

    man DT makes this all seem easy, but god theres alot to learn, kinda makes me want to try this, but im not sure if im ready for that, "yes i have Doom installed, trying to mess with it and learn some some stuff,

  • @DarkNoys
    @DarkNoys 4 ปีที่แล้ว +1

    it's awesome !!

  • @BalajiA
    @BalajiA 4 ปีที่แล้ว

    Excellent. Thanks for this illustration. I'm looking to rewrite and generate my .spacemacs this way.
    f e d opens up the dotfile .spacemacs. How can I make it open the spacemacs.org instead?

    • @bandithedoge
      @bandithedoge 3 ปีที่แล้ว

      hopefully you've found an answer in the 3 months since this comment was posted. in case you haven't, this spacemacs documentation page on binding keys might help: www.spacemacs.org/doc/DOCUMENTATION.html#binding-keys

  • @iqwrjwqioprwjriopqrjpqowir
    @iqwrjwqioprwjriopqrjpqowir 4 ปีที่แล้ว

    I support your videos about emacs, but you have to say the differences between emacs and doom emacs. Statements like "Press Y to yank this" or "

  • @leviticus8930
    @leviticus8930 4 ปีที่แล้ว +1

    I blame Comcast and Pulseaudio

  • @ste_ph_en9018
    @ste_ph_en9018 3 ปีที่แล้ว

    you missed an opportunity to show off magit the second best package in emacs!

  • @zweitlander874
    @zweitlander874 4 ปีที่แล้ว +1

    :)

  • @mortezabehboodian5758
    @mortezabehboodian5758 4 ปีที่แล้ว +1

    i came for i3 :|

    • @kaiocesar8578
      @kaiocesar8578 4 ปีที่แล้ว +1

      You don't need to evaluate the sources just do C-c C-c in the first line then C-c C-v t to tangle

    • @DistroTube
      @DistroTube  4 ปีที่แล้ว +2

      Yea, I stand corrected on this working with i3 and spectrwm. This will work for any file regardless of whether it's in a programming language since we aren't actually going to evaluate any of this code.

  • @semilin
    @semilin 4 ปีที่แล้ว +2

    Last

  • @MichaelMantion
    @MichaelMantion 3 ปีที่แล้ว +1

    2 minutes before he gets to it.... Sorry this is 2015, most people don't have time for this. That is why 96.3% of people watched your video and didn't bother to like or unlike it.
    You have a great voice, your nice to listen to, we all want to have a complete understanding. BUT start with the meat then explain it. Your video should be, This is Org mode in doom emacs, Her is a dot file. This is how you do it. THEN go and explain that you use doom and why "i use doom because It gives me Vi/VIM key controls and has a lot of customization I like. Then explain what org mode is and why and give more examples of how it works.

  • @usrname1105
    @usrname1105 4 ปีที่แล้ว +2

    FiRsT

    • @usrname1105
      @usrname1105 4 ปีที่แล้ว +2

      Damn bro that’s crazy, but I don’t remember anyone asking.