emacs color-theme by buffer - emacs

I'm in love with emacs. I don't believe there is anything one can't do with enough effort!
I have just fine working scripts/extensions installed that could be relevant to get my point:
org-mode (with a CAPTURE-TEMPLATE named "Journal")
color-theme (emacswiki)
theme-changer (github)
color-theme-buffer-local (github)
emacs-version: "GNU Emacs 23.3.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-03-25 on roseapple, modified by Debian"
Whats already working fine
When I'm starting a journal-entry trough my defined shortcut, what happens is the following:
emacs opens a new buffer("CAPTURE-journal.org") in a new window
I edit it
with another keystroke the entry gets refiled to my defined journal.org file
the buffer and the window are then closed automatically
I continue working on the file I worked before
What I want it to do additionally:
the "CAPTURE-journal.org"-buffer in the new window should have a unique color-theme, lets say color-theme-retro-orange
My .emacs with the code snippet I believe should be relevant.
I have no idea how to tackle this task. Where does one begin editing? Are even all tools needed for this listed above?

Seen from scratch: you need a list with color-themes
(setq my-themes (list "color-theme-retro-orange" "second-theme" "third...))
than you need a pointer, storing position used last.
See Emacs Lisp Intro chapter of kill-ring-save
When finished, bind that function at a suitable place, where-from your buffer is opened, resp. load it with the stuff mentioned by OP.
Or create a minor-mode, which will all new buffers provide with this.

Related

Emacs - How do I get projectile to open file in current window?

I've spent a whole day on this now. Say I open emacs and press C-c p p to open projectile-switch-project then RET to select a project, emacs opens a new window horizontally (on top of the previous) with the current buffer.
What I need is for projectile to use the already existing window and not open a new one. I've gone through every single line of my config and can figure out what is causing it.
I'd have posted my config but it's split over multiple files which will make it impractical to link to here.
The related packages I can think of which I use are:
projectile,
ivy swiper counsel - trilogy
What I've tried so far is start emacs without loading (ivy swiper counsel) and also I've tried replacing all my projectile code with bare minimum:
(use-package projectile
:ensure t
:init
(projectile-mode +1)
:bind (:map projectile-mode-map
("s-p" . projectile-command-map)
("C-c p" . projectile-command-map)))
which didn't work either.
I'm not expecting any specifics since it's a hand crafted config however I'm hoping for general pointes as to where to look for the possible cause.
I'm researching more to see if i can find a better way for you, but this is what i have so far...
If you want to look around the customization options just type M-x customize. I found a ton of options you can browse through. Projectile was listed under "Convenience" and frames/windows were listed under "Environment". You can also search packages you might be interested in for more customization if you have MELPA installed.
Considering the way that buffers and windows work I don't think you can just replace the content inside the buffer with the content of another file. I think (or at least how I've been using Emacs) you will always open a new buffer to open a file and close old buffers if needed.
From what I was reading, buffers are like interfaces between Emacs and the file you're peering into. It sets up a connection, points to the file, and creates a name for the buffer (usually from the file name unless you change it). Something I find interesting is you can even have multiple buffers open to the same file and as you type on the screen in one buffer the text should show up in the other buffer in real time.
I was reading some documentation on it and I think the command you're looking for is C-x C-f or C-x d, which opens DiredMode. The first one opens your home directory and the second opens the current directory for the file in your selected buffer. This will open a mini-buffer to search through files and when you choose the file it should open the file in a new buffer on top of the buffer you were looking at initially.
Then you can use C-x b to list and move between other buffers that are already open.
Also, M-x projectile-find-file is a command you can use to search files and get the same outcome. I don't have that set to a key-binding so I don't know if there is a default, plus I'm using Spacemacs with evil-mode, so not everything is the same as original Emacs.
Also, maybe look into extension you can get from MELPA like Treemacs

Use mit-scheme with REPL and editor together

I'm going through SICP course and as recommended installed mit-scheme. I want to use the REPL together with a scheme file. The reason is because I can add scheme code in the file and then run the commands in REPL. What I have works, but the problem is every time I edit the file, I have to quit terminal and reload the file for REPL to see changes.
Is there a way to reload the file easily or some other way for REPL to see changes from the file?
This my setup:
I installed mit-scheme with brew install mit-scheme
I have a local file named code.scm
In terminal, I load the file with mit-scheme --load /Users/name/Desktop/code.scm
Terminal now starts the REPL and everything works. The problem is that if I add new code to the file code.scm, I have to quit terminal and call this again: mit-scheme --load /Users/name/Desktop/code.scm
System details:
macOS Catalina - 10.15.6
Default Mac Terminal app - Version 2.10
MIT/GNU Scheme running under OS X
The text editor I use is Atom - 1.50.0
Question Edit #1 (Based on answer below)
I tried following instructions but this is complicated.
This is what I did:
Run mit-scheme < /Users/Desktop/code.scm
After this I ran mit-scheme --edit to open Edwin. I tried to use the code inside of the code.scm file but it doesn't recognize it. This is the code in code.scm file:
This is what I want to be able to do:
Notice in this picture, I can type a command, press enter and it automatically runs command. However, I want to be able to call (fib 5) and it references the function in code.scm file.
Could someone explain step by step how to do this? It's confusing looking at documentation for scheme websites.
There's actually a built-in load procedure available in the MIT Scheme REPL.
Evaluating
(load "path/to/file.scm")
causes the Scheme file located at path/to/file.scm to be evaluated at the top level (note that the double quotes around the file name are required).
And, as it turns out, this same function can be used to reload a file.
With this in mind, a possible "workflow" might look like this:
Create new source file
Evaluate (load "path/to/file.scm") in the REPL
Edit source file
Evaluate (load "path/to/file.scm") in the REPL
...etc.
Unfortunately, I don't think there is a built-in "reload" procedure.
But...if you find yourself reloading a lot (as I imagine you will), you can always quickly write your own at the beginning of a hacking session:
(define (reload)
(load "path/to/file.scm"))
And then just call (reload) whenever you make a change to your source file.
If you're interesting in using Emacs, I'd say it's worth a shot.
There's a bit of a learning curve, but it's not as steep as it looks up front :)
Also, I cannot recommend the Racket programming language(s) enough.
There is an incredibly straightforward way to set it up for SICP, and it's a much more forgiving environment than Emacs.
Let me know if you are interested and want any help getting started.
You should use emacs with xscheme.el. It works much better.
If you continue as you do, you can also do mit-scheme < code.scm or mit-scheme --edit code.scm and you will also get a *repl* buffer inside edwin.
I recommend you the emacs way, however.
A (load "/path/to/file") command should be available to you within MIT Scheme and the Edwin editor it comes with. However, I would actually recommend that you use Emacs, and use Geiser within that to access both the REPL and to help with scheme file editing. It also makes dealing with various Scheme REPLs such as Chez Scheme, Racket, MIT Scheme, Guile, Chicken, Gambit and Chibi Scheme fairly effortless. The same (load "/path/to/file") command would then be available to you within the REPL running under Geiser, within Emacs, but is generally much more powerful and seamless than when using the "naked" REPL. Emacs is very well tuned to use with Scheme and LISP. Highly recommended.
Evaluate entire buffer: press M-o (M is Alt on Windows). When in source file window, press it. It will evaluate the entire buffer i.e. (re)load the entire source file (without even saving it first). I found it by googling "mit scheme edwin tutorial". Edwin is kind of Emacs itself.
This page says: "C-c C-s when done in a scheme-mode buffer [i.e. Scheme source file window], will switch to the Scheme interaction buffer [i.e. REPL]". i.e. you press C-x C-s to save file, M-o to evaluate (i.e. load), C-c C-s to switch to the REPL.
If you've split your screen with C-x 2 between a source file buffer and the REPL ("interactions buffer"), you can switch between them by pressing C-x o (for "go to the other window").

Change default drag-and-drop behavior to open file in read-only mode

I just finished the Emacs Lisp intro and am getting my feet wet with customization. I've browsed the Emacs FAQ, the Emacs W32 FAQ, and perused the fine manual for drag and drop information. I am using GNU Emacs 24.5.1 for Windows without Cygwin (etc.).
I would like to update the default drag and drop behavior to open such files in read only mode. Through C-h f I've identified the dnd functions. In particular, dnd-open-file may be relevant. By C-h k and then dragging a file into Emacs, I've identified the function w32-drag-n-drop. Also, within the Reference Manual is a section on drag-and-drop which specifies x-dnd-types-alist.
How do I identify which of these items, if any, needs to be modified?
What is a safe way to modify its behavior?
I cannot find documentation on x-dnd-types-alist. Is it a function? A variable?
Is there a resource I've overlooked which I should be looking at?
Partial answers of a general nature - I can't help with your dnd problems,
but I hope these suggestions will be of some use.
Q2. It's a good idea to have a minimal init file, containing whatever is necessary to initialize an environment for testing. You can them invoke emacs like this:
emacs -q -l /path/to/minimal/init/file
bypassing your initialization file (-q) and loading the minimal init file instead. Then if something blows up, you just kill this emacs instance, and start again (possibly with a modified init file).
Q3. It's a variable (as are all alists). An alist (short for association list) is a list of key-value pairs. You can get the docstring of any variable with
C-h v VARNAME RET
e.g.
C-h v x-dnd-types-alist RET
Q4. If all else fails, the source is available...

Emacs command to Find and Open File similar to Eclipse

I've recently switched from using Eclipse to emacs. I'm trying to find a way to emulate eclipse's Ctrl-Shft-r functionality which lets you type in a file name and it begins showing all files in the current workspace that begin with the string you are typing.
C-x C-f seems to handle just tab-completion in the current directory, whereas Eclipse's functionality looked through all sub-directories to find matching files.
I'm looking for something (maybe there's a plugin that does this) that allows you to type the name of folder to look in, and then a partial file and returns back the results in a buffer. Possibly that uses auto-complete to list off matching files with their full paths.
First of all, steer clear of vanilla find-file function (that's the interactive function that is run when you hit C-x C-f). It is very limited, it forces you to hit TAB all the time, and the first thing most people do when switching to emacs is replace find-file with something more powefull.
There're a number of alternatives. ido-mode is one, helm is another. The former is light-weight, fast and comes built-in with emacs. The latter is immensely powerful and strives to be fast, too.
Second of all, there're two ways a recursive file search can usually be done:
directory search - that's when you just search a directory, no surprises here;
project search - that's when you setup a project your're working on, thus making emacs aware of which files are of interest to you right now.
For directory search, ido-find-file and helm-find-file are both viable options. Ido does its search automatically when you pause typing; helm uses (C-u) M-g s to activate grep. See this SO question for more info.
For project search, you need a library to manage your projects. Projectile is great for that. Set it up and use C-c p f or C-c p F to list files in current or all of your projects, respectively. Oh, and projectile uses ido by default, but there is helm support, too.
You're looking for projectile which indexes your project's files. I used it for a while but have recently switched to using helm-recentf
(global-set-key "\C-x\ \C-r" 'helm-recentf)
I have recent files set to a large number. Pretty much anything I've ever opened is a few keystrokes away. This even doubles up as a handy way to switch buffers.
(require 'recentf)
(setq recentf-auto-cleanup 'never)
(recentf-mode 1)
(setq recentf-max-saved-items 200)

I want to try org-mode. What's the shortest path from zero to typing?

I want to give emacs' org-mode a try. What is the shortest path for me to accomplish that?
Assume NO previous experience with emacs.
(I'm aware that other editors, like vim and textmate, have similar task lists. I'm specifically interested in learning about the emacs org-mode)
My laptop runs Win7 Home Premium x64
I use Emacs (when I'm on Windows) with the official binaries at http://ftp.gnu.org/gnu/emacs/windows/emacs-22.3-barebin-i386.zip Just unzip to a directory and double click "runemacs".
In all the commands that follow, C stands for Ctrl.
Create a file ending in .org. If using recent Emacs, that will automatically start org-mode. You can create a file using C-x C-f.
Start creating outlines like this:
* Level 1
** Level 2
Collapse/Uncollapse outline levels with TAB
Todo's you can cycle by hitting C-c C-t
That's the basics, and pretty much all I know, but I already use it extensively :)
Have a look at the tutorials on http://orgmode.org/worg/org-tutorials/
I started org mode with an article in the linux journal and a very useful & simply tutorial.
David O'Toole Org tutorial
Get Organized with Emacs Org-mode
Both sources give you in my opinion a superb and fast introduction to org mode.
Start org mode with M-x org-mode RET, or by visiting a file with the .org extension.
Type C-h m in an org mode buffer to see the (brief) mode description and (importantly) all of its key-bindings.
Type C-h i m org RET to read the Org Mode manual.
(Typing q will bury either of the *Help* or *info* buffers.)
Visit the web site at http://orgmode.org/ for more.
I found a very extensive list of youtube video regarding org-mode. See it here : Org-Mode on Youtube. Use the latest Emacs release, it already has org-mode installed. Create a file with .org extension. Now, type the title of the file, then start create these:
* Roles
** Role 1
*** Todo 1
*** Todo 2
*** Todo 3
** Role 2
*** Todo 1
*** Todo 2
While your cursor on Role1, press TAB and see the way org-mode hide/show the only relevant tree structure. Press tab again to toggle the visibility status.
Now, while you are in Role 1, type C-x n s, or the command org-narrow-to-subtree. It will only displayed Role 1. To get back, use the command widen, or C-x n w.
I found it very helpful!
Lots of other great stuff in org-mode
By the way, you can easily convert and display in browser your org-file. Type : org-export-as-html-and-open. I use it a lot!
Since others already mentioned how to install and start using org-mode, I would like to point you to the excellent collection of tutorials on Worg (it is a community driven documentation effort in the form of tutorials, How tos and other articles).
Everyone starts Emacs without previous experience.You just need to:
Install Emacs
Install org-mode
Use org-mode to write something
I think both Emacs and org-mode are well documented.So if you have any trouble, read the official documents.
That's all. Good luck.
Org-mode beginning at the basics sounds promising, it starts with
The absolute minimum you need to know about Emacs
The absolute minimum you need to know about Emacs, to be able to do
anything, is more then you need to know about many other applications.
But, you might compare it to a regular toy and lego. Lego is harder to
begin with (you start with a box with little plastic pieces), but in
the long run, you can do more with it.
I have a portable version with .emacs configure ready, which setup org mode, etc. It also included org sample file. I think that is a better start point.
http://nd.edu/~gsong/portable_emacs.html
Best,