Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Hollow Talk
Feb 2, 2014

PlesantDilemma posted:

What's the deal with org mode HTML export? I added a
code:
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="http://mysite.com/org-style.css">
block to my .org file, but when I export it I don't see any <link> tag in the head. The basic CSS that it generates is not great and I want to replace it.

Edit:
I'm running Emacs 24, Org 7.9.3f, on Windows 7

The HTML_HEAD option has been introduced in Org 8.x, if I am not mistaken. Since you are using the old stable version, you will have to use the older form:

code:
#+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
You can find a bit more background here: https://stackoverflow.com/questions/16453427/cant-get-emacs-org-mode-to-use-my-css-file

Adbot
ADBOT LOVES YOU

Hollow Talk
Feb 2, 2014

PlesantDilemma posted:

Yessssss Thanks for this buddy. The org docs don't mention the version requirements. I guess I should look into upgrading...

Glad I could help! For what it's worth, I've been running 8.x for quite a while without any problems, and I'm using it heavily. If you want to upgrade, you can find out about changes that break backwards compatibility (one of which is the html_head thing) here: http://orgmode.org/worg/org-8.0.html

The normal ELPA gnu repository (via list-packages) has an updated version from yesterday, which, I presume, is simply a git snapshot.

Hollow Talk
Feb 2, 2014

Deus Rex posted:

As for remembering open files, I personally keep an emacs process running all the time with a server, and connect to it with emacsclient if I need to open something from the command line. Emacs also ships with desktop-save-mode which persists a list of open buffers when you close Emacs.

Daemon mode is a godsend anyway because it also allows you to connect either the normal GUI client or the console client, depending on what you need in any given situation. I have the following set in my .bashrc/.zshrc (though it's part of an if-clause there):

code:
export EDITOR='emacsclient -c -a ""'
export VISUAL='emacsclient -c -a ""'
What this means is: -c creates a new emacs frame while -a "" sets the alternative editor to an empty string, which means a new emacs --daemon is started if it was not running before, instead of emacsclient simply not starting. I have them aliased to shorter commands, like so:

code:
alias em="$EDITOR -t"
alias emc=$VISUAL
The -t in the em-alias starts the console interface, the other one uses the normal GUI.

Hollow Talk
Feb 2, 2014

Deus Rex posted:

Turn on ido-mode and install smex.



Ever since somebody first pointed out ido-mode to me, this has been one of the things that improved my life the most ever since I started using Emacs. The latter makes searching for and executing commands much easier (and gives a nice history of past commands, which is rather handy when you use the same things repeatedly), while the former makes looking for and opening files just so much better and intuitive.

For ido-mode, I use:
code:
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
And for SMEX:
code:
(eval-after-load "smex-autoloads"
  '(progn
     (global-set-key (kbd "M-x") 'smex)
     (global-set-key (kbd "M-X") 'smex-major-mode-commands)
					; This is your old M-x.
     (global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
     (setq smex-save-file "~/.emacs.d/.smex.last")))

Hollow Talk
Feb 2, 2014

pgroce posted:

Amen. And even stock Emacs is sensitive to the fact that the cut and paste commands are idiosyncratic; the Mac builds by default map Command-x/c/v to cut/copy/paste. (I unbind them because I use Command as Meta, and also I'm cranky and hate change. (Friends don't let friends use cua-mode.))


The most helpful command for figuring out what key maps to what (and what you might be overwriting) is describe-key (bound to C-h k). It will also tell you if a key is not bound.

If you're still concerned about keeping the default keybinds around (a lot of them are quite useful, and it's nice not to be completely lost when you sit down at someone else's Emacs :) ), here's another tip. In addition to Control and Meta, Emacs also uses the Super and Hyper modifiers, but because modern keyboards don't have Super and Hyper keys, there aren't many commands mapped to use those modifiers, and the ones that remain are, shall we say, non-essential. If you have a seldom-used key on your keyboard (I use the right control key), you can bind it to one of those seldom-used modifiers (I use Super) and do whatever the hell you want.

How you do this is platform-specific. Noted I-guess-not-homeless-guy Xah Lee explains how to use Super and Hyper on Windows and Mac. (All the mac-prefixed variables he mentions are now aliases for variables prefixed with ns- because RMS is a big nerd. You can use either, but I guess mac- might go away someday. Maybe.)

Presumably one does this on Linux through either X keymaps or terminal escape code voodoo, depending on whether you're running Emacs on the terminal or in a GUI window. I haven't dealt with that in years, hopefully someone knowledgeable can chime in.

On Linux, I have Hyper mapped to Capslock, though I don't use it in Emacs but for i3wm as my general mod-key there. It's a bit of a pain to do though; I used Xmodmap (and ~/.Xmodmap as the config file for it) to unbind the modifiers, set they specific keys via keycodes, then reassigned the modifiers, which ends up looking like this:

code:
clear Lock
clear Mod1
clear Mod3
clear Mod4
keycode 64 = Alt_L
keycode 66 = Hyper_L
keycode 135 = Multi_key
add Mod1 = Alt_L
add Mod3 = Hyper_L Hyper_R
add Mod4 = Meta_L Meta_R
That said, I'm not sure whether your keycodes are necessarily going to be the same, so that's something you'd have to try. Also be careful with unbinding keys, because you can do stupid things. An alternative you can try is modifying ~/.Xkbmap, though I've had mixed success with this.

Hollow Talk fucked around with this message at 01:33 on Jul 3, 2014

Hollow Talk
Feb 2, 2014

PlesantDilemma posted:

So I used M-x upcase-region and got a warning about it often confusing new users. What's the story on that? Is it doing something besides just making all the letters capitol? I was surprised by the warning.

Essentially, there are some functions which the average (or new) user usually doesn't use or that would confuse them. One such example is the narrowing down of a buffer which might sometimes be useful but to a new user might seem like most of their document just vanished. M-x upcase-region is probably another such function, because it won't be used that often, hence the warning. It's really just a way to keep people from activating something unknowingly yet still giving people who do need the functionality a way to do so. When the message pops up, you will also get presented with a number of shortcuts in the minibuffer, which are essentially "use despite warning" or "cancel", but also "unlock for future use", which means you won't see the warning again as a variable is written to your profile file.

Essentially, upcase-region will do exactly what it says, it's just that what it does is rarely what most people would want. If you need to use it, just do, there aren't any other undocumented consequences!

Hollow Talk
Feb 2, 2014

ynohtna posted:

On top of what Hollow Talk correctly states, upcase-region is also mapped by default to a key sequence that a new user may invoke accidentally before they have learnt the core of how Emacs works and - vitally - how to invoke the essential undo operation.

Quite right. I still sometimes hit some of these functions without wanting to despite not being all that new to Emacs, and I'm glad it warns me instead of running weird commands.

Hollow Talk
Feb 2, 2014

Surprise T Rex posted:

So I grabbed Emacs yesterday after getting frustrated with the poor state of Python Autocompletion in Sublime Text compared to C#'s IntelliSense in VS2013. I sort of came into it with the mindset of "Well I'll pick either Emacs or Vim to have a go at learning, and if I can't wrap my head around it then I'll give in and keep going with ST3."

Last night I felt like I might be about to give in, but I loaded it up at work today and just casually opened up my .emacs, took out the scroll and toolbars, saved it and had a look around the buffer menu and stuff, without needing to think too much. It's... not easy, I guess, just not quite as incomprehensible as I first thought it might be.

It got a lot easier too when I gave up on using the C-[whatever] shortcuts to move the point and just went back to 'proper' keyboard cursor movement.

Give it time. People's .emacs configs tend to evolve over time (it never ends! :saddowns:). Do use whatever feels most natural, be it things like CUA Mode, cursor movement or some such. Be prepared to also get told years and years into using it about package x or y, which will magically solve a problem you've had, a hack you've been using or just make everything easier, making you question how you ever managed to live without it.

At least installing packages has become easier with M-x list-packages...

Hollow Talk
Feb 2, 2014

Surprise T Rex posted:

Org-mode is fantastic. It's brilliant for whipping up quick internal documentation and stuff. Write it out in loose bullet points, add headings, C-c, C-e, h. You have a formatted HTML page, if a little bare-looking.

If you haven't made good use of it yet you really need to.

You can style the html it generates with css and even with javascript, though. That might at least help a bit with the bareness: http://orgmode.org/manual/CSS-support.html#CSS-support

If you find yourself using it more often like that, have a look at the Publishing module (http://orgmode.org/manual/Publishing.html#Publishing) as well. It lets you define "projects" and can format the html and copy it elsewhere, together with images, stylesheets etc.

I practically live in org-mode, since I use that for all of my notes (and Emacs+LaTeX+RefTeX for writing), and it really is fantastic!

Hollow Talk
Feb 2, 2014

pgroce posted:

Coincidentally, someone whose blog I read just did an article on using Edebug, the Emacs interactive debugger. It uses a slightly different entry mechanism than toggle-debug-on-error, but it's probably a little more what you were looking for.

Specifically regarding org-mode: I've had shenanigans ensue when I upgrade org-mode (as a package, not the built-in version) because it byte-compiles files in a copy of Emacs where the old versions of the symbols are already loaded. This doesn't sound like the case for you, but it's worth being aware of. You should also remove any other copies that might be in the load path -- e.g., in .emacs.d/elpa, or wherever ELPA puts packages on Windows.

Org is the reason I now only upgrade ELPA packages from a clean version of Emacs with almost nothing loaded.

I have had some grief with org-mode on upgrades before as well, so I started simply building it from the git tree itself instead of using ELPA. That way, at least, it just installs it properly (in this case) in /usr/local/share/emacs/site-lisp, and not in an ELPA directory somewhere in my home folder.

Hollow Talk
Feb 2, 2014

midnightclimax posted:

I've started dabbling around with org-mode, and I'd like to know if it's possible to resize images inline kinda like the timg tag does within this forum. So far I've found some post saying to put #+Attr.*: width="20px" (20px is just a random number, a relative value would be optimal) before my image like
#+Attr.*: width="20px"
file:~/pic.jpg
but nothing happens, it just shows up like before.

Is this for html export? If so, try to put an attribute in front of the link:
code:
#+ATTR_HTML: :width 100px
[[./foo.bar]]
Width takes any of the common html/css units, so you can use px, pt, em or %.

edit: On second thought, this is about inline in the buffer, isn't it? Either way, it seems (perhaps unintuitively) that the ATTR_HTML thing works regardless. Here is what the variable description for org-image-actual-width has to say:

quote:

Should we use the actual width of images when inlining them?

When set to `t', always use the image width.

When set to a number, use imagemagick (when available) to set
the image's width to this value.

When set to a number in a list, try to get the width from any
#+ATTR.* keyword if it matches a width specification like

#+ATTR_HTML: :width 300px

and fall back on that number if none is found.

When set to nil, try to get the width from an #+ATTR.* keyword
and fall back on the original width if none is found.

This requires Emacs >= 24.1, build with imagemagick support.

You can customize this variable.

This variable was introduced, or its default value was changed, in
version 24.4 of Emacs.

edit2: It seems however that inline images don't work with % or em or some such. You also don't have to use ATTR_HTML, but ATTR: :width 100 works as well. Another option would be to just set a default value for org-image-actual-width, use (setq org-image-actual-width '(100)) to make org-mode take into account whatever you set in a separate case-by-case #+ATTR, and otherwise just use that size.

Hollow Talk fucked around with this message at 20:33 on Jan 5, 2015

Hollow Talk
Feb 2, 2014

midnightclimax posted:

None of these work (yes it's primarily about inline display in the buffer). I've installed ImageMagick via MacPorts to see if that's the culprit, but I get the same behaviour as before (using the stock mac os x emacs binary).

The above work on openSUSE with Emacs 24.4.1 with ImageMagick support, but I have not tried this under OS X. My strong suspicion is that the standard Emacs build does not enable ImageMagick support at compile time, which is necessary as far as I know. Do MacPorts have their own version of Emacs, by chance? :saddowns:

Hollow Talk
Feb 2, 2014

wooger posted:

As an exclusive evil-mode user, this really looks like it could be of value, though I've only just started playing around really. I get the sense that they've bundled a few too many tools by default.

I get the feeling that usually fits most of these bundles (oh-my-zsh is another one that comes to mind). I like to have a look at them and see how they solve particular problems, and I tend to find an interesting or useful solution to a problem I have as well (or that I didn't even know I have had until then :saddowns:); yet there are always so many things in there that seem counterintuitive, that I would never use or which I don't understand which make me hesitant to "just use" them.

Hollow Talk
Feb 2, 2014
It might also help to enable debugging via (setq debug-on-error t), just to see whether something obviously throws an error right that moment.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Error-Debugging.html

Hollow Talk
Feb 2, 2014

midnightclimax posted:

Hmm well that didn't show anything. Unless it outputs to some file I can't find.

Hmpf, that's interesting. Errors bring up a new frame with debugging enabled, so you didn't miss anything. :(

Hollow Talk
Feb 2, 2014

midnightclimax posted:

Eh, I just opened a file and realized I must have cut a large chunk without yanking it someplace else. Guess I need to use some kind of versioning control. I'm using Emacs mostly with org to write memos, journals, etc. Do I just use vc git?

e: Learned about the way emacs does backups, and customized my .emacs accordingly.

Regardless, git works great for org files, since they are plain text. The only problem with running "proper" vc on things like org and LaTeX files is that git (like all vc tools I know) works by lines, which is very useful for programming, but sometimes a bit annoying with text. In the end, all it means however is that you get slightly bigger diff files, and git diff --word-diff can highlight changed words rather than whole lines. I don't use much of the emacs git integration, other than the diff viever (vc-diff) and the history viewer, since I do my commits from the console and then write my commit messages in Emacs. It's worth it, though.

Hollow Talk
Feb 2, 2014
This is also only vaguely related, but I have similar problems even with something relatively simple like flyspell and large org-mode buffers, where I have to disable flycheck because it slows down too much, so this might either be a bottleneck for things that need to run over the whole document, or it might be some sort of problem with big buffers. Org-mode's own unfolding of large sectioning takes a while with its own commands as well, while show-all works almost instantly. So this might be a problem depending on how exactly the auto-completion/checker etc. is written and how extensively it has to do things with big files.

Hollow Talk
Feb 2, 2014

pgroce posted:

On June 10, the Marmalade repo's certificate expired. (Yay, encryption everywhere.) Since then, my attempts to update package lists from there have failed. There seems to be no hurry to fix it; I left a bug on Github and, in desperation, even tweeted Nic Ferrier about it. No one cares, I guess.

I've seen no one else talking about this, so I assume there's an easy workaround. (I'm on Emacs 24.4 still, so maybe the answer is "use Emacs 24.5"?) Suggestions would be appreciated.

From what I can see, it produces an error with 24.5(.1) as well, so the answer isn't "use Emacs 24.5". :saddowns:

Hollow Talk
Feb 2, 2014

wooger posted:

You can do this in software pretty easily FWIW. However, I've found that moving Ctrl to the alt key, alt to the win key & escape to CapsLock is by far the most ergonomic layout for me. Ctrl on escape is still using the pinky on the left side only far too much.

Caveat: I use evil-mode

In true Emacs spirit, one can never have enough modifier keys, so my CapsLock key is bound to Hyper, which gives me Meta (Win), Alt, Ctrl, Shift & Hyper. :colbert:

Hollow Talk
Feb 2, 2014

MALE SHOEGAZE posted:

Source control, man. :cool:

This is pretty much the correct answer. Use something like git (or svn or some such), put your config in there, and use something like github, bitbucket (they offer free private repositories) or a server you own to push your configuration. Then clone the repository on your other system, and there you go. The only thing you have to be a bit careful with is to put architecture/OS specific things in there without any kind of test, if-statement etc., since that might break one system while happily working on the other.

Hollow Talk
Feb 2, 2014

Love Stole the Day posted:

I recently learned how to do the most basic M-x org-mode stuff like C-c C-t so I've been using it to keep a basic to-do list with learning the Unreal Engine. I thought it might be cool to post a picture here since this thread isn't very active and could use more content.

The more I learn about this Emacs stuff, the more I like it. I really love how it lets me never have to reach for my mouse anymore. I've actually gotten to the point now where regardless of what text editor I'm in (e.g. notepad++, lua, VS) I always do C-x C-s out of habit and automatically do C-s C-g whenever I catch myself accidentally doing it the old way.



The manual for org-mode on their website is too intimidating even though each page seems to just be a couple paragraphs. Hopefully one day I'll get the inspiration to grind through it and learn how to do the more cool stuff like make exportable HTML tables and whatnot.



edit-- i also learned about M-x doctor and M-x tetris recently. emacs is cool as poo poo.

org-mode is love, org-mode is life. I actually use it for note-taking and for presentations, because its LaTeX Beamer export allows for the much nicer org-mode markup that kind of translates heading levels into frames etc. instead of having to do it by hand. org-mode and LaTeX/RefTeX are the two main reasons why I started using Emacs to begin with.

I'm not a big a fan of using it for mail (though I know at least one person who does use it), but it's also a decent development platform. I use Geiser for Scheme/Racket stuff.

Hollow Talk
Feb 2, 2014

horse mans posted:

Ctrl-[ is a much more convenient shortcut for Esc in vim anyway, since each key is within normal typing distance.

Sure, if you use an American keyboard.

Hollow Talk
Feb 2, 2014

MALE SHOEGAZE posted:

Anyone who stops for 10 seconds to think "wow, I press these buttons all the time and they're in terrible spots, maybe I should rebind them"

Lots of people probably just rebind CAPSLOCK as their ESC key, which is a lot more convenient.

Of course, serious users use CAPSLOCK as Hyper key for their tiling window manager in order to not clash with their myriad of Emacs keybindings. :v:

Adbot
ADBOT LOVES YOU

Hollow Talk
Feb 2, 2014

Nude posted:

Hey guys so I wanted to key bind a theme in Emacs, with this code here:
code:
(global-set-key (kbd "C-c a") '(load-theme 'tao-yang))
So (load-theme 'tao-yang) works fine in the lisp evaluation buffer. But I get the "Wrong type of argument: commando" error when trying to make it a key bind, which upon research I take that to mean I have to use the interactive function. But my understanding is the interactive function is used for creating functions that are interactive not for already made functions. So now I'm just confused, is there any way to hotkey a function that requires an interactive parameter by putting the parameter through code not user input?

Also I was wondering if there was a way to make it so when I press a modifier it would come up immediately in the buffer rather than waiting 1 second to see if I hit C-x or something. Been trying to google this for hours but can't seem to get a clear answer. Thanks for any help as usual :).

Basically, the problem here is that load-theme is defined interactively, as per (interactive-form 'load-theme)

code:
(interactive (list (intern (completing-read "Load custom theme: " ...)) nil nil))
We can further check (commandp 'load-theme), which yields t.

The normal way to execute this would be (command-execute 'load-theme), which calls (call-interactively 'load-theme) internally. However, that means the function call still tries to honour the interactive definition, which means it still tries to get the theme name from the minibuffer, because the command loop looks for that.

GNU Emacs Lisp Reference Manual posted:

The interactive form must be located at top-level in the function body, or in the function symbol’s interactive-form property (see Symbol Properties). It has its effect because the command loop looks for it before calling the function (see Interactive Call). Once the function is called, all its body forms are executed; at this time, if the interactive form occurs within the body, the form simply returns nil without even evaluating its argument.

So if you supply your own call to interactive first, the rest will be run as-is, i.e. in this case without paying attention to its own interactive definition. Since global-set-key doesn't take interactive functions, your version yields an error while (global-set-key (kbd "C-c a") (lambda () (interactive nil) (load-theme 'tao-yang))) works. Since lambda is the function in this case, calling an empty interactive function (both (interactive) and (interactive nil) work) means the rest of your function body gets executed as is, which means this essentially binds (load-theme 'tao-yang) "non-interactively", letting you supply the argument directly by "overriding" its internal interactive function. It's...not great design.

tl;dr: After calling interactive once, all subsequent calls to interactive in the function body get treated as nil.

  • Locked thread