NB: Some of the below tips are outdated (particularly those before 2020) and I don't follow them any more.
Refer to my .emacs file for the best practices I am now using (the linked file is for Emacs 29)
  1. 2024, November: successful installation of Emacs 29 (Ubuntu 20.04)
  2. After I installed Emacs 28 I became frustrated that lsp-mode and the overall machinery I used to get TypeScript IntelliSense in Emacs was too slow, so I thought I might try to upgrade to Emacs 29. Installing Emacs 29 wasn't possible as apparently it's only available as a snap. I initially found this emacs stackexchange answer and was then led to these instructions. Installing Emacs 29 was only a matter of doing:

    sudo snap install emacs --classic
    and modifying my ~/.bashrc to place the /snap/bin directory at the front of the PATH to ensure that emacs on the shell picks Emacs 29 and not Emacs 28 (which was installed with apt)

    Following the installation I just removed a number of packages that were no longer available (nor, it would seem, relevant as nothing was affected following their removal), moved the main package installation block at the head of my .emacs file and started off with a clean .emacs.d directory. Everything went surprisingly smoothly.

  3. 2024, November: successful installation of Emacs 28 (Ubuntu 20.04)
  4. Following a previous disastrous attempt to install Emacs 27 in my ThinkStation desktop (running Ubuntu 20.04) I tried again the next day and succeeded to actually install Emacs 28 instead.

    I followed the instructions from here (which are pretty much what I tried the previous day); only this time I thoroughly uninstalled Emacs 26 alongside a number of extra packages using the following incantation:

    sudo apt remove emacs26-common emacs26 emacs-common emacs apel flim w3m-el emacs-el emacs-bin-common
    … as advised in a comment in the above linked instructions that reads:
    Dan Jones December 23, 2020 at 2:58 pm
    I kept getting unmet dependency errors.

    I had to remove a lot of extra packages for this to work.

    sudo apt remove emacs26-common emacs26 emacs-common emacs apel flim w3m-el emacs-el emacs-bin-common

    After that, I could finally do sudo apt install emacs27 and it worked.

    It also had to re-download all of my packages on the first run, so the first run was especially slow.

    But now, everything’s fine.

    Indeed following the above instructions sudo apt install emacs28 worked like a charm with zero complaints or warnings; not only that but my configuration files (developed and tested for Emacs 26) also worked right off the bat with zero modifications needed. This was, by a wide margin, the most uneventful Emacs upgrade ever.

    For completeness purposes, this is the history (slightly edited) in the terminal from where I performed the installation:

     $ sudo add-apt-repository ppa:kelleyk/emacs
     $ apt update
     $ sudo apt remove emacs26-common emacs26 emacs-common emacs apel flim w3m-el emacs-el emacs-bin-common
     $ sudo apt install emacs28
    Note finally that I did try to install the very latest Emacs 29 also but apparently it is not available in the ppa:kellyk/emacs repository. Well, no matter.

    I will now try to refresh the Emacs packages and see whether I can finally succeed in installing IntelliSense for TypeScript in my Emacs 28.

    follow-up

    While trying to refresh the package implementations, it turned out that I also had to remove the crosshairs package from my .emacs file as that package does not support versions of Emacs beyond 26. During the package refresh process I also had to do (setq package-check-signature nil) — this dangerous line is currently commented-out at the head of my .emacs file. Note that I think that the package refresh process wasn't triggered until I removed the .emacs.d directory from my home directory. At the same time I decided that it makes little or zero sense to keep the .emacs.d directory under git source control.

    Finally, unrelated to the previous package refreshing issues, I had to fix my emax script that handles multiple Emacs clients out of a single Emacs server. The fix consisted of a minor grep adjustment.

  5. 2024, November: failure to install Emacs 27 and Language Server on Ubuntu 20.04
  6. In November 2024 I spent about 5 hours trying to install Emacs 27 on Ubuntu 20.04. In the end I failed. Large part of the time spent was in trying to restore Emacs 26.3 (which is what Ubuntu 20.04 supports officially).

    As part of the same travail I failed to install lsp-mode (so as to have TypeScript language server facilities and IntelliSense in Emacs); it was verified that Emacs 27.1 is required. I was following instructions from here.

  7. 2019, November: how I installed Emacs 25 on Ubuntu 16.04
  8. Following the instructions from here I did the following:

    sudo add-apt-repository ppa:kelleyk/emacs
    sudo apt install emacs25
    $ emacs --version | head -1
    GNU Emacs 24.5.1
    $ emacs25 --version | head -1
    GNU Emacs 25.3.2

    Subsequently, I configured alternatives for emacs:

    $ sudo update-alternatives --config emacs
    [sudo] password for mperdikeas:
    There are 2 choices for the alternative emacs (providing /usr/bin/emacs).
    
      Selection    Path                Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/emacs24-x   27        auto mode
      1            /usr/bin/emacs24-x   27        manual mode
      2            /usr/bin/emacs25     27        manual mode
    
    Press <enter> to keep the current choice[*], or type selection number: 2
                update-alternatives: using /usr/bin/emacs25 to provide /usr/bin/emacs (emacs) in manual mode
    $
    $
    $ emacs --version | head -1
    GNU Emacs 25.3.2
    

  9. how to rebuild ELPA packages
  10. source

    I have encountered cases where an emacs installation would behave erratically with certain key-bindings not working as expected given the packages I've installed. This could be due to an Emacs upgrade and the ELPA packages requiring rebuilding.

    Based on the source link above (and given that my package-user-dir variable was apparently not set), I've used the following:

    M-: (byte-recompile-directory package-user-dir nil 'force)

    … to rebuild the packages. When I re-launced Emacs things seemed to be working more smoothly.

    If, for some weird reason the package-user-dir variable is not set (use C-h v to inspect it) you can also provide the directory as a string literal:
    M-: (byte-recompile-directory package-user-dir "/home/mperdikeas/.emacs.d/elpa" nil 'force)

    BTW, M-: can be used to evaluate any expression in the minibuffer.

  11. key information
  12. C-h k

    … followed by an arbitrary key sequence shows which command is mapped to that key sequence.
  13. mode information
  14. C-h m
    to get information about major and minor modes
    C-h f json-mode
    to get information about a particular mode

    and a link to the file that defines.
  15. solve the dreaded C-SPACE sequence key not working in emacs
  16. I was beset by this problem when I installed Emacs24 on Ubuntu 14.04.5 on the Dell Precision laptop (August '16)

    Basically what happens is that the C-SPACE combo is hijacked by the ibus program and not recognized as a sequence in Emacs. When you ssh to the computer from another machine that doesn't suffer from this problem the combo works as expected (this proves that the problem is not in Emacs but rather in the desktop environment).

    Follow these instructions.

    Core of the solution:

    In 14.04, you can edit the settings directly is dconf-editor.

    If it is not installed:

    sudo apt install dconf-editor

    Then browse to Desktop >> ibus >> general >> hotkey. The trigger and triggers setting will still show 'control+space'. Edit these settings out, being careful to leave empty brackets [] in triggers.

  17. solve the dreaded M- problem in Org-mode on tty
  18. Use these alternative key bindings as suggested in this answer.
  19. how to disable ALT key hijacking in Unity when working with Emacs
  20. Follow these instructions.

    Basically install ccsm (CompizConfig Settings Manager):

    sudo apt-get install CompizConfig-Settings-Manager.
                
    … then run ccsm and select Desktop / Ubuntu Unity Plugin and disable the "Key to show the menu bar while pressed" and possibly "Key to show the HUD when tapped" too.

    Basically disable everything bound to the ALT key to be on the safe side.

  21. how to load a module in Emacs and associate it with a file extension
  22. It is a three-step process:
    1. extend the load-path to include the directory where the *.el file for the mode lives
    2. load the module
    3. associate the module with the file extension
    This is nicely shown in the below excrept from my .emacs file:
    (progn
        (add-to-list 'load-path "~/.emacs.d/web-mode/")
        (load "web-mode")
        (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
    )
              
    It is advisable that that the el file lives in a git submodule.
  23. how to view the value of a variable in Emacs
  24. Use the function describe-variable (usually bound to C-h v)
  25. replace tabs / spaces in Emacs
  26. The way to do it is via M-x tabify or M-x untabify. These functions work on the current selection, so to apply them to the whole buffer do a C-x h beforehand.
  27. how to install Emacs24 on Ubuntu
  28. I followed the instructions found here:

    https://launchpad.net/~cassou/+archive/emacs

    (I got there from:

    http://askubuntu.com/questions/149562/how-to-upgrade-to-emacs-24-1

    )

    Be sure to also read the instructions in the link of the "Signing key". After the "sudo apt-get update" I then did a "sudo apt-get install emacs24" and had Emacs 24 installed.

    ================================================================

    Before succeeding I tried following these instructions instead:

    http://batsov.com/articles/2011/10/09/getting-started-with-emacs-24/

    (which points you to: http://emacs.naquadah.org/ )

    but it didn't work. The reason was that I was being silly because the link at http:emacs.naquadah.org ALSO points to Damien Cassou's page (it says: "If you are looking for the Ubuntu packages, Damien Cassou now maintains an emacs-snapshot PPA.") but I was tired and my eyes were sore and didn't notice it.